Read the genotype, phenotype and fitness information of evolved populations of 3000 network topology samples.
jointResultsFolder = "20211201_40node_0.05dens_joint_topos"
pathToJointResultsFolder = paste0("../results/", jointResultsFolder)
# read results and split into sel & neutr
allNetsResults_joint <- read.table(paste0(pathToJointResultsFolder, "/allNetsResults_prepped_joint.txt"),
sep = "\t", header = TRUE)
# rename nets
allNetsResults_joint[allNetsResults_joint$topo == "BA", "net"] <-
allNetsResults_joint[allNetsResults_joint$topo == "BA", "net"] + 1000
allNetsResults_joint[allNetsResults_joint$topo == "WS", "net"] <-
allNetsResults_joint[allNetsResults_joint$topo == "WS", "net"] + 2000
allNetsResults_joint$topo <- factor(allNetsResults_joint$topo, levels = c("ER", "BA", "WS"))
############### Filter 1
# keep only pure regulators and purely regulated genes
justRegulators <- allNetsResults_joint[allNetsResults_joint$absInStr == 0, ]
justRegulated <- allNetsResults_joint[allNetsResults_joint$absOutStr == 0, ]
allNetsResults_joint <- rbind(justRegulators, justRegulated)
selResults <- allNetsResults_joint[allNetsResults_joint$scen == "sel", ]
neutrResults <- allNetsResults_joint[allNetsResults_joint$scen == "neu", ]
# subset responded genes
respondedToSelCutoff <- 0.5
# add which genes responded to selection
selResults$responseToSel <- selResults$s_g_area_abs > respondedToSelCutoff
# subset the genes that responded to selection
respondedGenes <- selResults[selResults$responseToSel == TRUE, ]
library(nlme)
library(MuMIn) # for r.squared in lme models
library(ggplot2)
library(ggpubr) # for the pubclean theme
library(ggridges)
library(gridExtra)
library(cowplot) # for arranging plots
##
## Attaching package: 'cowplot'
## The following object is masked from 'package:ggpubr':
##
## get_legend
library(infotheo)
library(lme4)
## Loading required package: Matrix
##
## Attaching package: 'lme4'
## The following object is masked from 'package:nlme':
##
## lmList
library(car) # for vif measure
## Loading required package: carData
library(RColorBrewer) # for color palettes
library(latex2exp) # for latex notation in the plots
library(reshape2)
library("Hmisc") # for correlation matrix
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
##
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
##
## format.pval, units
library(corrplot) # for plotting correlation matrix
## corrplot 0.90 loaded
library(ade4) # for PCA
library(factoextra) # for scree plot
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
library(FSA) # for Dunn tests
## Registered S3 methods overwritten by 'FSA':
## method from
## confint.boot car
## hist.boot car
## ## FSA v0.9.3. See citation('FSA') if used in publication.
## ## Run fishR() for related website and fishR('IFAR') for related book.
##
## Attaching package: 'FSA'
## The following object is masked from 'package:car':
##
## bootCase
library(rstatix) # for partial eta for lms
##
## Attaching package: 'rstatix'
## The following object is masked from 'package:stats':
##
## filter
library(dplyr) # for summarizing dataframes
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:Hmisc':
##
## src, summarize
## The following object is masked from 'package:car':
##
## recode
## The following object is masked from 'package:gridExtra':
##
## combine
## The following object is masked from 'package:nlme':
##
## collapse
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
# MI
calcInformation <- function (v1, v2, binNum) {
# discretize
d_v1 <- discretize(v1, nbins = binNum);
d_v2 <- discretize(v2, nbins = binNum)
# mutual information
I_v1v2 <- mutinformation(d_v1, d_v2);
return("MI" = I_v1v2)
}
# colors for plots
noiseColor = "#01665e"
genotypeColor = "#7b3294"
phenotypeColor = "#d95f0e"
fitnessColor = "#e78ac3"
neutralityColor = "darkgray"
MIColor = "#2c7fb8"
topoColors = c("ER" = "darkgray", "BA" = "#c51b7d", "WS" = "#4d9221")
netAllResults <- allNetsResults_joint %>%
group_by(scen, net) %>%
summarize(ave_varP_1 = mean(varP_1),
ave_varP_10000 = mean(varP_10000),
ave_relDeltaVar_10000 = mean(relDeltaVar_10000),
ave_s_g_area_abs = mean(s_g_area_abs),
topo = first(topo))
## `summarise()` has grouped output by 'scen'. You can override using the `.groups` argument.
netSelResults <- selResults %>%
group_by(scen, net) %>%
summarize(ave_varP_1 = mean(varP_1),
ave_varP_10000 = mean(varP_10000),
ave_relDeltaVar_10000 = mean(relDeltaVar_10000),
ave_s_g_area_abs = mean(s_g_area_abs),
ave_responseToSel = length(which(responseToSel)),
topo = first(topo))
## `summarise()` has grouped output by 'scen'. You can override using the `.groups` argument.
evolMetricsColnames <- c("meanG_1", "meanG_10000",
"meanP_1", "meanP_10000",
"varP_1", "varP_10000",
"CVP_1", "CVP_10000",
"noiseP_1", "noiseP_10000",
"FanoP_1", "FanoP_10000",
"relDeltaVar_1", "relDeltaVar_10000",
"relDeltaCV_1", "relDeltaCV_10000",
"relDeltaNoise_1", "relDeltaNoise_10000",
"relDeltaFano_1", "relDeltaFano_10000",
"s_g_area", "s_g_area_abs",
"s_p_area_relDeltaVar", "s_p_area_relDeltaCV",
"s_p_area_relDeltaNoise", "s_p_area_relDeltaFano")
evolMetricsColnames_ofInterest <- c("varP_1", "relDeltaVar_10000", "s_g_area_abs")
geneSpecificNetMetricsColnames <- c("k_all_inclps", "k_in_inclps", "k_out_inclps",
"clo_all", "betw", "eigen_centr",
"str_all_inclps", "str_in_inclps", "str_out_inclps",
"hub_score", "auth_incwght", "auth_excwght",
"absstr_all_inclps", "absInStr", "absOutStr",
"flow", "load", "info", "stress",
"absInStrT_sqrt", "absOutStrT_sqrt",
"absInStrT_log1p", "absOutStrT_log1p",
"absInStrT_log10", "absOutStrT_log10")
geneSpecificNetMetricsColnames_ofInterest <- c("k_all_inclps", "k_in_inclps", "k_out_inclps",
"clo_all", "betw", "eigen_centr",
"str_all_inclps", "str_in_inclps", "str_out_inclps",
"hub_score", "auth_incwght", "auth_excwght",
"absstr_all_inclps", "absInStr", "absOutStr",
"flow", "load", "info", "stress")
globalNetMetricsColnames <- c("diam", "meandst", "assort",
"cntr_degr_all", "cntr_indegr", "cntr_outdegr", "cntr_clo_all", "cntr_betw",
"ave_k_all_inclps", "ave_k_in_inclps","ave_k_out_inclps")
singletsSelResults <- selResults[!duplicated(selResults$net), c("net", globalNetMetricsColnames)]
netSelResults <- merge(netSelResults, singletsSelResults, by = "net")
singletsAllResults <- allNetsResults_joint[!duplicated(allNetsResults_joint$net), c("net", globalNetMetricsColnames)]
netAllResults <- merge(netAllResults, singletsAllResults, by = "net")
# wrap around scenario
ggplot(data = allNetsResults_joint, aes(y = varP_1, x = topo)) +
geom_boxplot(width = 0.2, alpha = 0.8, outlier.alpha = 0, fill = noiseColor) +
facet_wrap(~scen) +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
labs(x = "Network topology",
y = expression(bold("Expr. variance, gen 1")))
# wrap around scenario
ggplot(data = allNetsResults_joint, aes(y = varP_10000, x = topo)) +
geom_boxplot(width = 0.2, alpha = 0.8, outlier.alpha = 0, fill = noiseColor) +
facet_wrap(~scen) +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
ylab(expression(bold("Expr. variance, gen 10k"))) +
xlab("Network topology")
# wrap around scenario
ggplot(data = allNetsResults_joint, aes(y = relDeltaVar_10000, x = topo)) +
geom_boxplot(width = 0.2, alpha = 0.8, outlier.alpha = 0, fill = noiseColor) +
facet_wrap(~scen) +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
ylab(expression(bold("Rel."~Delta~"expr. variance"))) +
xlab("Network topology")
## Warning: Removed 15 rows containing non-finite values (stat_boxplot).
# wrap around scenario
ggplot(data = allNetsResults_joint, aes(y = s_g_area_abs, x = topo)) +
geom_boxplot(width = 0.2, alpha = 0.8, outlier.alpha = 0, fill = genotypeColor) +
facet_wrap(~scen) +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = genotypeColor, "neutr" = genotypeColor)) +
ylab(expression(paste(bold("Selective pressure "), "|", bold(p), "|"))) +
xlab("Network topology")
my_comparisons <- list( c("ER", "BA"), c("BA", "WS"), c("WS", "ER") )
# just selection
plot_varFirstgen_sel <- ggplot(selResults, aes(y = varP_1, x = topo)) +
geom_violin(aes(fill = topo), trim = TRUE) +
geom_boxplot(width = 0.05, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_compare_means(comparisons = my_comparisons, label = "p.signif", method = "wilcox.test") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label=round(..y.., digits=2))) +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "right") +
scale_fill_manual(values = topoColors) +
labs(x = "Network topology",
y = "Expr. variance, gen 1",
fill = "Topology")
plot_varFirstgen_sel
ggsave(filename = sprintf("plot_varFirstgen_sel.png"),
plot = plot_varFirstgen_sel,
path = pathToPlotsFolder,
device = "png", scale = 2, width = 6, height = 5.5, units = "cm",
dpi = 300, limitsize = TRUE)
# just selection
plot_varLastgen_sel <- ggplot(selResults, aes(y = varP_10000, x = topo)) +
geom_violin(aes(fill = topo), trim = TRUE) +
geom_boxplot(width = 0.05, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_compare_means(comparisons = my_comparisons, label = "p.signif", method = "wilcox.test") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label=round(..y.., digits=2))) +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "right") +
scale_fill_manual(values = topoColors) +
labs(x = "Network topology",
y = "Expr. variance, gen 10k",
fill = "Topology")
plot_varLastgen_sel
ggsave(filename = sprintf("plot_varLastgen_sel.png"),
plot = plot_varLastgen_sel,
path = pathToPlotsFolder,
device = "png", scale = 2, width = 6, height = 5.5, units = "cm",
dpi = 300, limitsize = TRUE)
# just selection
plot_relDeltaVar_sel <- ggplot(selResults, aes(y = relDeltaVar_10000, x = topo)) +
geom_violin(aes(fill = topo), trim = TRUE) +
geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label = round(..y.., digits = 3))) +
stat_compare_means(comparisons = my_comparisons, label = "p.signif", method = "wilcox.test") +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "right") +
scale_fill_manual(values = topoColors) +
labs(x = "Network topology",
y = expression(bold("Rel."~Delta~"expr. variance")),
fill = "Topology")
plot_relDeltaVar_sel
## Warning: Removed 11 rows containing non-finite values (stat_ydensity).
## Warning: Removed 11 rows containing non-finite values (stat_boxplot).
## Warning: Removed 11 rows containing non-finite values (stat_summary).
## Warning: Removed 11 rows containing non-finite values (stat_signif).
ggsave(filename = sprintf("plot_relDeltaVar_sel.png"),
plot = plot_relDeltaVar_sel,
path = pathToPlotsFolder,
device = "png", scale = 2, width = 6, height = 5.5, units = "cm",
dpi = 300, limitsize = TRUE)
## Warning: Removed 11 rows containing non-finite values (stat_ydensity).
## Warning: Removed 11 rows containing non-finite values (stat_boxplot).
## Warning: Removed 11 rows containing non-finite values (stat_summary).
## Warning: Removed 11 rows containing non-finite values (stat_signif).
# just selection
plot_selpress_sel <- ggplot(selResults, aes(y = s_g_area_abs, x = topo)) +
geom_violin(aes(fill = topo), trim = TRUE) +
geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = 3, color = "black", aes(label = round(..y.., digits = 3))) +
stat_compare_means(comparisons = my_comparisons, label = "p.signif", method = "wilcox.test") +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "right") +
scale_fill_manual(values = topoColors) +
labs(x = "Network topology",
y = expression(paste(bold("Selective pressure "), "|", bold(p), "|")),
fill = "Topology")
plot_selpress_sel
ggsave(filename = sprintf("plot_selpress_sel.png"),
plot = plot_selpress_sel,
path = pathToPlotsFolder,
device = "png", scale = 2, width = 6, height = 5.5, units = "cm",
dpi = 300, limitsize = TRUE)
plot_violin_metrics_per_topo <- plot_grid(plot_varFirstgen_sel,
plot_varLastgen_sel,
plot_relDeltaVar_sel,
plot_selpress_sel,
scale = c(0.95, 0.95, 0.95, 0.95),
labels = "AUTO",
label_size = 20,
label_fontface = "bold")
## Warning: Removed 11 rows containing non-finite values (stat_ydensity).
## Warning: Removed 11 rows containing non-finite values (stat_boxplot).
## Warning: Removed 11 rows containing non-finite values (stat_summary).
## Warning: Removed 11 rows containing non-finite values (stat_signif).
ggsave(filename = sprintf("plot_violin_metrics_per_topo.png"),
plot = plot_violin_metrics_per_topo,
bg = "white",
path = pathToPlotsFolder,
device = "png", scale = 1.8, width = 17, height = 12, units = "cm",
dpi = 300, limitsize = TRUE)
ggsave(filename = sprintf("plot_violin_metrics_per_topo.tiff"),
plot = plot_violin_metrics_per_topo,
bg = "white",
path = pathToPlotsFolder,
device = "tiff", scale = 1.8, width = 17, height = 12, units = "cm",
dpi = 300, limitsize = TRUE)
summary(selResults$varP_1[selResults$topo == "BA"])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0869 207.2131 339.2046 399.4414 522.9711 2085.7390
summary(selResults$varP_1[selResults$topo == "ER"])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0126 95.5801 97.4367 256.8216 276.7556 2338.3050
summary(selResults$varP_1[selResults$topo == "WS"])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.1128 95.4661 97.1606 334.2331 407.7409 2316.1060
summary(selResults$varP_10000[selResults$topo == "BA"])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.00 10.68 13.55 15.81 18.16 572.43
summary(selResults$varP_10000[selResults$topo == "ER"])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 2.443 6.434 16.566 14.423 1580.068
summary(selResults$varP_10000[selResults$topo == "WS"])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 1.523 2.598 24.109 17.282 1688.977
summary(selResults$relDeltaVar_10000[selResults$topo == "BA"])
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## -1.0000 -0.9396 -0.9251 -0.9183 -0.9013 -0.1855 5
summary(selResults$relDeltaVar_10000[selResults$topo == "ER"])
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## -1.0000 -0.9517 -0.9154 -0.9076 -0.8792 0.5344 4
summary(selResults$relDeltaVar_10000[selResults$topo == "WS"])
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## -1.00000 -0.96954 -0.95185 -0.92578 -0.90441 0.01619 2
summary(selResults$s_g_area_abs[selResults$topo == "BA"])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0000079 0.8274448 0.8475506 0.7857834 0.8609779 0.9862562
summary(selResults$s_g_area_abs[selResults$topo == "ER"])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0000174 0.8328644 0.8769063 0.8213445 0.9485889 0.9845167
summary(selResults$s_g_area_abs[selResults$topo == "WS"])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0000113 0.7597390 0.9222863 0.7565365 0.9666924 0.9858500
kruskal.test(varP_1 ~ topo, data = selResults)
##
## Kruskal-Wallis rank sum test
##
## data: varP_1 by topo
## Kruskal-Wallis chi-squared = 5637.3, df = 2, p-value < 2.2e-16
kruskal.test(varP_10000 ~ topo, data = selResults)
##
## Kruskal-Wallis rank sum test
##
## data: varP_10000 by topo
## Kruskal-Wallis chi-squared = 3814, df = 2, p-value < 2.2e-16
kruskal.test(relDeltaVar_10000 ~ topo, data = selResults)
##
## Kruskal-Wallis rank sum test
##
## data: relDeltaVar_10000 by topo
## Kruskal-Wallis chi-squared = 899.23, df = 2, p-value < 2.2e-16
kruskal.test(s_g_area_abs ~ topo, data = selResults)
##
## Kruskal-Wallis rank sum test
##
## data: s_g_area_abs by topo
## Kruskal-Wallis chi-squared = 2895.5, df = 2, p-value < 2.2e-16
pairwise.wilcox.test(selResults$varP_1, selResults$topo, paired = FALSE, p.adjust.method = "BH")
##
## Pairwise comparisons using Wilcoxon rank sum test
##
## data: selResults$varP_1 and selResults$topo
##
## ER BA
## BA <2e-16 -
## WS 0.17 <2e-16
##
## P value adjustment method: BH
pairwise.wilcox.test(selResults$varP_10000, selResults$topo, paired = FALSE, p.adjust.method = "BH")
##
## Pairwise comparisons using Wilcoxon rank sum test
##
## data: selResults$varP_10000 and selResults$topo
##
## ER BA
## BA <2e-16 -
## WS <2e-16 <2e-16
##
## P value adjustment method: BH
pairwise.wilcox.test(selResults$relDeltaVar_10000, selResults$topo, paired = FALSE, p.adjust.method = "BH")
##
## Pairwise comparisons using Wilcoxon rank sum test
##
## data: selResults$relDeltaVar_10000 and selResults$topo
##
## ER BA
## BA <2e-16 -
## WS <2e-16 <2e-16
##
## P value adjustment method: BH
pairwise.wilcox.test(selResults$s_g_area_abs, selResults$topo, paired = FALSE, p.adjust.method = "BH")
##
## Pairwise comparisons using Wilcoxon rank sum test
##
## data: selResults$s_g_area_abs and selResults$topo
##
## ER BA
## BA < 2e-16 -
## WS 1.3e-09 < 2e-16
##
## P value adjustment method: BH
# ER to BA
wilcox.test(selResults$varP_1[selResults$topo == "ER"], selResults$varP_1[selResults$topo == "BA"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_1[selResults$topo == "ER"] and selResults$varP_1[selResults$topo == "BA"]
## W = 78202824, p-value < 2.2e-16
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$varP_1[selResults$topo == "ER"], selResults$varP_1[selResults$topo == "BA"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_1[selResults$topo == "ER"] and selResults$varP_1[selResults$topo == "BA"]
## W = 78202824, p-value = 1
## alternative hypothesis: true location shift is greater than 0
# BA to WS
wilcox.test(selResults$varP_1[selResults$topo == "BA"], selResults$varP_1[selResults$topo == "WS"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_1[selResults$topo == "BA"] and selResults$varP_1[selResults$topo == "WS"]
## W = 62934704, p-value = 1
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$varP_1[selResults$topo == "BA"], selResults$varP_1[selResults$topo == "WS"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_1[selResults$topo == "BA"] and selResults$varP_1[selResults$topo == "WS"]
## W = 62934704, p-value < 2.2e-16
## alternative hypothesis: true location shift is greater than 0
# WS to ER
wilcox.test(selResults$varP_1[selResults$topo == "WS"], selResults$varP_1[selResults$topo == "ER"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_1[selResults$topo == "WS"] and selResults$varP_1[selResults$topo == "ER"]
## W = 18070078, p-value = 0.9157
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$varP_1[selResults$topo == "WS"], selResults$varP_1[selResults$topo == "ER"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_1[selResults$topo == "WS"] and selResults$varP_1[selResults$topo == "ER"]
## W = 18070078, p-value = 0.08434
## alternative hypothesis: true location shift is greater than 0
# ER to BA
wilcox.test(selResults$varP_10000[selResults$topo == "ER"], selResults$varP_10000[selResults$topo == "BA"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_10000[selResults$topo == "ER"] and selResults$varP_10000[selResults$topo == "BA"]
## W = 93007528, p-value < 2.2e-16
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$varP_10000[selResults$topo == "ER"], selResults$varP_10000[selResults$topo == "BA"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_10000[selResults$topo == "ER"] and selResults$varP_10000[selResults$topo == "BA"]
## W = 93007528, p-value = 1
## alternative hypothesis: true location shift is greater than 0
# BA to WS
wilcox.test(selResults$varP_10000[selResults$topo == "BA"], selResults$varP_10000[selResults$topo == "WS"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_10000[selResults$topo == "BA"] and selResults$varP_10000[selResults$topo == "WS"]
## W = 62394860, p-value = 1
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$varP_10000[selResults$topo == "BA"], selResults$varP_10000[selResults$topo == "WS"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_10000[selResults$topo == "BA"] and selResults$varP_10000[selResults$topo == "WS"]
## W = 62394860, p-value < 2.2e-16
## alternative hypothesis: true location shift is greater than 0
# WS to ER
wilcox.test(selResults$varP_10000[selResults$topo == "WS"], selResults$varP_10000[selResults$topo == "ER"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_10000[selResults$topo == "WS"] and selResults$varP_10000[selResults$topo == "ER"]
## W = 14649206, p-value < 2.2e-16
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$varP_10000[selResults$topo == "WS"], selResults$varP_10000[selResults$topo == "ER"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$varP_10000[selResults$topo == "WS"] and selResults$varP_10000[selResults$topo == "ER"]
## W = 14649206, p-value = 1
## alternative hypothesis: true location shift is greater than 0
# ER to BA
wilcox.test(selResults$relDeltaVar_10000[selResults$topo == "ER"], selResults$relDeltaVar_10000[selResults$topo == "BA"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$relDeltaVar_10000[selResults$topo == "ER"] and selResults$relDeltaVar_10000[selResults$topo == "BA"]
## W = 157663321, p-value = 1
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$relDeltaVar_10000[selResults$topo == "ER"], selResults$relDeltaVar_10000[selResults$topo == "BA"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$relDeltaVar_10000[selResults$topo == "ER"] and selResults$relDeltaVar_10000[selResults$topo == "BA"]
## W = 157663321, p-value < 2.2e-16
## alternative hypothesis: true location shift is greater than 0
# BA to WS
wilcox.test(selResults$relDeltaVar_10000[selResults$topo == "BA"], selResults$relDeltaVar_10000[selResults$topo == "WS"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$relDeltaVar_10000[selResults$topo == "BA"] and selResults$relDeltaVar_10000[selResults$topo == "WS"]
## W = 59418100, p-value = 1
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$relDeltaVar_10000[selResults$topo == "BA"], selResults$relDeltaVar_10000[selResults$topo == "WS"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$relDeltaVar_10000[selResults$topo == "BA"] and selResults$relDeltaVar_10000[selResults$topo == "WS"]
## W = 59418100, p-value < 2.2e-16
## alternative hypothesis: true location shift is greater than 0
# WS to ER
wilcox.test(selResults$relDeltaVar_10000[selResults$topo == "WS"], selResults$relDeltaVar_10000[selResults$topo == "ER"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$relDeltaVar_10000[selResults$topo == "WS"] and selResults$relDeltaVar_10000[selResults$topo == "ER"]
## W = 12376522, p-value < 2.2e-16
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$relDeltaVar_10000[selResults$topo == "WS"], selResults$relDeltaVar_10000[selResults$topo == "ER"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$relDeltaVar_10000[selResults$topo == "WS"] and selResults$relDeltaVar_10000[selResults$topo == "ER"]
## W = 12376522, p-value = 1
## alternative hypothesis: true location shift is greater than 0
# ER to BA
wilcox.test(selResults$s_g_area_abs[selResults$topo == "ER"], selResults$s_g_area_abs[selResults$topo == "BA"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$s_g_area_abs[selResults$topo == "ER"] and selResults$s_g_area_abs[selResults$topo == "BA"]
## W = 199304563, p-value = 1
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$s_g_area_abs[selResults$topo == "ER"], selResults$s_g_area_abs[selResults$topo == "BA"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$s_g_area_abs[selResults$topo == "ER"] and selResults$s_g_area_abs[selResults$topo == "BA"]
## W = 199304563, p-value < 2.2e-16
## alternative hypothesis: true location shift is greater than 0
# BA to WS
wilcox.test(selResults$s_g_area_abs[selResults$topo == "BA"], selResults$s_g_area_abs[selResults$topo == "WS"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$s_g_area_abs[selResults$topo == "BA"] and selResults$s_g_area_abs[selResults$topo == "WS"]
## W = 34962826, p-value < 2.2e-16
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$s_g_area_abs[selResults$topo == "BA"], selResults$s_g_area_abs[selResults$topo == "WS"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$s_g_area_abs[selResults$topo == "BA"] and selResults$s_g_area_abs[selResults$topo == "WS"]
## W = 34962826, p-value = 1
## alternative hypothesis: true location shift is greater than 0
# WS to ER
wilcox.test(selResults$s_g_area_abs[selResults$topo == "WS"], selResults$s_g_area_abs[selResults$topo == "ER"],
alternative = "less")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$s_g_area_abs[selResults$topo == "WS"] and selResults$s_g_area_abs[selResults$topo == "ER"]
## W = 19025992, p-value = 1
## alternative hypothesis: true location shift is less than 0
wilcox.test(selResults$s_g_area_abs[selResults$topo == "WS"], selResults$s_g_area_abs[selResults$topo == "ER"],
alternative = "greater")
##
## Wilcoxon rank sum test with continuity correction
##
## data: selResults$s_g_area_abs[selResults$topo == "WS"] and selResults$s_g_area_abs[selResults$topo == "ER"]
## W = 19025992, p-value = 6.685e-10
## alternative hypothesis: true location shift is greater than 0
dunnTest(varP_1 ~ topo, data = selResults, method = "bh")
## Dunn (1964) Kruskal-Wallis multiple comparison
## p-values adjusted with the Benjamini-Hochberg method.
## Comparison Z P.unadj P.adj
## 1 BA - ER 70.732677 0.000000e+00 0.000000e+00
## 2 BA - WS 37.047204 1.992008e-300 2.988012e-300
## 3 ER - WS -6.283547 3.309342e-10 3.309342e-10
dunnTest(varP_10000 ~ topo, data = selResults, method = "bh")
## Dunn (1964) Kruskal-Wallis multiple comparison
## p-values adjusted with the Benjamini-Hochberg method.
## Comparison Z P.unadj P.adj
## 1 BA - ER 54.248428 0.000000e+00 0.000000e+00
## 2 BA - WS 38.459852 0.000000e+00 0.000000e+00
## 3 ER - WS 4.470447 7.805611e-06 7.805611e-06
dunnTest(relDeltaVar_10000 ~ topo, data = selResults, method = "bh")
## Warning: Some rows deleted from 'x' and 'g' because missing data.
## Dunn (1964) Kruskal-Wallis multiple comparison
## p-values adjusted with the Benjamini-Hochberg method.
## Comparison Z P.unadj P.adj
## 1 BA - ER -9.328486 1.073942e-20 1.073942e-20
## 2 BA - WS 26.454708 3.220889e-154 4.831333e-154
## 3 ER - WS 29.807682 3.106342e-195 9.319026e-195
dunnTest(s_g_area_abs ~ topo, data = selResults, method = "bh")
## Dunn (1964) Kruskal-Wallis multiple comparison
## p-values adjusted with the Benjamini-Hochberg method.
## Comparison Z P.unadj P.adj
## 1 BA - ER -50.598093 0.000000e+00 0.000000e+00
## 2 BA - WS -26.794244 3.770905e-158 5.656358e-158
## 3 ER - WS 4.224145 2.398500e-05 2.398500e-05
lmeModel <- lm(ave_varP_1 ~ topo,
data = netSelResults)
summary(lmeModel)
##
## Call:
## lm(formula = ave_varP_1 ~ topo, data = netSelResults)
##
## Residuals:
## Min 1Q Median 3Q Max
## -307.39 -96.31 -19.44 75.00 795.96
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 253.764 4.752 53.41 <2e-16 ***
## topoBA 144.574 6.720 21.52 <2e-16 ***
## topoWS 76.479 6.720 11.38 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 150.3 on 2997 degrees of freedom
## Multiple R-squared: 0.1339, Adjusted R-squared: 0.1333
## F-statistic: 231.7 on 2 and 2997 DF, p-value: < 2.2e-16
r.squaredGLMM(lmeModel)
## Warning: 'r.squaredGLMM' now calculates a revised statistic. See the help page.
## R2m R2c
## [1,] 0.1338396 0.1338396
lmeModel <- lm(ave_varP_10000 ~ topo,
data = netSelResults)
summary(lmeModel)
##
## Call:
## lm(formula = ave_varP_10000 ~ topo, data = netSelResults)
##
## Residuals:
## Min 1Q Median 3Q Max
## -22.96 -9.11 -2.93 1.56 589.73
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 16.4413 0.8746 18.800 < 2e-16 ***
## topoBA -0.6317 1.2368 -0.511 0.61
## topoWS 6.9718 1.2368 5.637 1.89e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 27.66 on 2997 degrees of freedom
## Multiple R-squared: 0.0153, Adjusted R-squared: 0.01464
## F-statistic: 23.28 on 2 and 2997 DF, p-value: 9.307e-11
r.squaredGLMM(lmeModel)
## R2m R2c
## [1,] 0.01528564 0.01528564
lmeModel <- lm(ave_relDeltaVar_10000 ~ topo,
data = netSelResults[!is.na(netSelResults$ave_relDeltaVar_10000), ])
summary(lmeModel)
##
## Call:
## lm(formula = ave_relDeltaVar_10000 ~ topo, data = netSelResults[!is.na(netSelResults$ave_relDeltaVar_10000),
## ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.06208 -0.01474 -0.00369 0.00676 0.51569
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.907371 0.001077 -842.428 < 2e-16 ***
## topoBA -0.010728 0.001524 -7.041 2.36e-12 ***
## topoWS -0.021157 0.001522 -13.896 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03399 on 2986 degrees of freedom
## Multiple R-squared: 0.06075, Adjusted R-squared: 0.06012
## F-statistic: 96.56 on 2 and 2986 DF, p-value: < 2.2e-16
r.squaredGLMM(lmeModel)
## R2m R2c
## [1,] 0.06070823 0.06070823
lmeModel <- lm(ave_s_g_area_abs ~ topo,
data = netSelResults)
summary(lmeModel)
##
## Call:
## lm(formula = ave_s_g_area_abs ~ topo, data = netSelResults)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.50854 -0.04530 0.01795 0.06470 0.22208
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.822174 0.003491 235.543 < 2e-16 ***
## topoBA -0.038220 0.004936 -7.742 1.32e-14 ***
## topoWS -0.062431 0.004936 -12.647 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.1104 on 2997 degrees of freedom
## Multiple R-squared: 0.05147, Adjusted R-squared: 0.05084
## F-statistic: 81.32 on 2 and 2997 DF, p-value: < 2.2e-16
r.squaredGLMM(lmeModel)
## R2m R2c
## [1,] 0.05143955 0.05143955
logRegModel <- glmer(responseToSel ~ (absInStrT_sqrt + absOutStrT_sqrt)*topo + (1|net),
data = selResults,
family = binomial,
control = glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e5)))
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model is nearly unidentifiable: large eigenvalue ratio
## - Rescale variables?
summary(logRegModel)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula: responseToSel ~ (absInStrT_sqrt + absOutStrT_sqrt) * topo + (1 |
## net)
## Data: selResults
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
##
## AIC BIC logLik deviance df.resid
## 18541.6 18628.0 -9260.8 18521.6 41659
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -26.3651 0.0255 0.1684 0.2672 2.6012
##
## Random effects:
## Groups Name Variance Std.Dev.
## net (Intercept) 0.9637 0.9817
## Number of obs: 41669, groups: net, 3000
##
## Fixed effects:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 5.43726 0.15640 34.765 < 2e-16 ***
## absInStrT_sqrt -2.13880 0.07867 -27.188 < 2e-16 ***
## absOutStrT_sqrt 1.94031 0.52414 3.702 0.000214 ***
## topoBA 0.46064 0.19123 2.409 0.016006 *
## topoWS -0.86377 0.31192 -2.769 0.005619 **
## absInStrT_sqrt:topoBA 0.33688 0.09754 3.454 0.000553 ***
## absInStrT_sqrt:topoWS 0.26994 0.14342 1.882 0.059812 .
## absOutStrT_sqrt:topoBA 6.49253 27.29003 0.238 0.811952
## absOutStrT_sqrt:topoWS -0.34327 0.74054 -0.464 0.642980
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) abIST_ abOST_ topoBA topoWS aIST_:B aIST_:W aOST_:B
## absInStrT_s -0.930
## absOtStrT_s -0.212 0.208
## topoBA -0.779 0.731 0.171
## topoWS -0.467 0.440 0.104 0.384
## absInST_:BA 0.727 -0.789 -0.167 -0.931 -0.356
## absInST_:WS 0.479 -0.525 -0.112 -0.395 -0.953 0.425
## absOtST_:BA 0.001 -0.001 -0.004 0.000 0.000 0.000 0.000
## absOtST_:WS 0.147 -0.145 -0.708 -0.120 -0.246 0.117 0.242 0.002
## optimizer (bobyqa) convergence code: 0 (OK)
## Model is nearly unidentifiable: large eigenvalue ratio
## - Rescale variables?
lmeModel <- lme(varP_1 ~ (absInStrT_sqrt + absOutStrT_sqrt)*topo,
data = selResults,
weights = varExp(form = ~absInStrT_sqrt),
random = ~1|net,
method = "ML")
summary(lmeModel)
## Linear mixed-effects model fit by maximum likelihood
## Data: selResults
## AIC BIC logLik
## 530282 530385.6 -265129
##
## Random effects:
## Formula: ~1 | net
## (Intercept) Residual
## StdDev: 0.002098466 16.60517
##
## Variance function:
## Structure: Exponential of variance covariate
## Formula: ~absInStrT_sqrt
## Parameter estimates:
## expon
## 1.671959
## Fixed effects: varP_1 ~ (absInStrT_sqrt + absOutStrT_sqrt) * topo
## Value Std.Error DF t-value p-value
## (Intercept) 92.25516 0.616642 38663 149.60898 0.0000
## absInStrT_sqrt 170.20212 1.681359 38663 101.22891 0.0000
## absOutStrT_sqrt 1.96797 0.356312 38663 5.52317 0.0000
## topoBA -22.96140 1.410795 2997 -16.27551 0.0000
## topoWS 1.44146 1.648891 2997 0.87420 0.3821
## absInStrT_sqrt:topoBA 14.24043 2.152554 38663 6.61560 0.0000
## absInStrT_sqrt:topoWS 18.86547 4.895200 38663 3.85387 0.0001
## absOutStrT_sqrt:topoBA 3.14079 0.444762 38663 7.06172 0.0000
## absOutStrT_sqrt:topoWS -1.01531 0.770348 38663 -1.31799 0.1875
## Correlation:
## (Intr) abIST_ abOST_ topoBA topoWS aIST_:B aIST_:W
## absInStrT_sqrt -0.417
## absOutStrT_sqrt -0.932 0.388
## topoBA -0.437 0.182 0.407
## topoWS -0.374 0.156 0.349 0.163
## absInStrT_sqrt:topoBA 0.326 -0.781 -0.303 -0.589 -0.122
## absInStrT_sqrt:topoWS 0.143 -0.343 -0.133 -0.063 -0.303 0.268
## absOutStrT_sqrt:topoBA 0.747 -0.311 -0.801 -0.818 -0.279 0.515 0.107
## absOutStrT_sqrt:topoWS 0.431 -0.180 -0.463 -0.188 -0.956 0.140 0.292
## aOST_:B
## absInStrT_sqrt
## absOutStrT_sqrt
## topoBA
## topoWS
## absInStrT_sqrt:topoBA
## absInStrT_sqrt:topoWS
## absOutStrT_sqrt:topoBA
## absOutStrT_sqrt:topoWS 0.371
##
## Standardized Within-Group Residuals:
## Min Q1 Med Q3 Max
## -4.15462098 -0.38314226 0.01162088 0.39563871 10.57670283
##
## Number of Observations: 41669
## Number of Groups: 3000
r.squaredGLMM(lmeModel)
## R2m R2c
## [1,] 0.9851681 0.9851681
lmeModel <- lme(relDeltaVar_10000 ~ (absInStrT_sqrt + absOutStrT_sqrt)*topo,
data = respondedGenes,
weights = varExp(form = ~absInStrT_sqrt),
random = ~1|net,
method = "ML")
summary(lmeModel)
## Linear mixed-effects model fit by maximum likelihood
## Data: respondedGenes
## AIC BIC logLik
## -151293.7 -151191.2 75658.86
##
## Random effects:
## Formula: ~1 | net
## (Intercept) Residual
## StdDev: 0.01166078 0.03251968
##
## Variance function:
## Structure: Exponential of variance covariate
## Formula: ~absInStrT_sqrt
## Parameter estimates:
## expon
## -0.01197058
## Fixed effects: relDeltaVar_10000 ~ (absInStrT_sqrt + absOutStrT_sqrt) * topo
## Value Std.Error DF t-value p-value
## (Intercept) -0.8707051 0.0009603748 35062 -906.6305 0.0000
## absInStrT_sqrt -0.0075292 0.0006612911 35062 -11.3856 0.0000
## absOutStrT_sqrt -0.0372652 0.0005450875 35062 -68.3656 0.0000
## topoBA -0.0003553 0.0012791051 2997 -0.2778 0.7812
## topoWS -0.0277004 0.0025448951 2997 -10.8847 0.0000
## absInStrT_sqrt:topoBA -0.0196596 0.0008104486 35062 -24.2577 0.0000
## absInStrT_sqrt:topoWS 0.0166816 0.0014179834 35062 11.7643 0.0000
## absOutStrT_sqrt:topoBA 0.0175102 0.0006030258 35062 29.0372 0.0000
## absOutStrT_sqrt:topoWS 0.0105677 0.0011953368 35062 8.8408 0.0000
## Correlation:
## (Intr) abIST_ abOST_ topoBA topoWS aIST_:B aIST_:W
## absInStrT_sqrt -0.789
## absOutStrT_sqrt -0.813 0.753
## topoBA -0.751 0.592 0.611
## topoWS -0.377 0.298 0.307 0.283
## absInStrT_sqrt:topoBA 0.644 -0.816 -0.614 -0.814 -0.243
## absInStrT_sqrt:topoWS 0.368 -0.466 -0.351 -0.276 -0.868 0.381
## absOutStrT_sqrt:topoBA 0.735 -0.681 -0.904 -0.696 -0.277 0.690 0.317
## absOutStrT_sqrt:topoWS 0.371 -0.343 -0.456 -0.279 -0.909 0.280 0.831
## aOST_:B
## absInStrT_sqrt
## absOutStrT_sqrt
## topoBA
## topoWS
## absInStrT_sqrt:topoBA
## absInStrT_sqrt:topoWS
## absOutStrT_sqrt:topoBA
## absOutStrT_sqrt:topoWS 0.412
##
## Standardized Within-Group Residuals:
## Min Q1 Med Q3 Max
## -4.2536274 -0.5631427 -0.1680720 0.3664331 22.4474219
##
## Number of Observations: 38068
## Number of Groups: 3000
r.squaredGLMM(lmeModel)
## R2m R2c
## [1,] 0.3136463 0.3918414
lmeModel <- lme(s_g_area_abs ~ (absInStrT_sqrt + absOutStrT_sqrt)*topo,
data = respondedGenes,
weights = varExp(form = ~absInStrT_sqrt),
random = ~1|net,
method = "ML")
summary(lmeModel)
## Linear mixed-effects model fit by maximum likelihood
## Data: respondedGenes
## AIC BIC logLik
## -139841.1 -139738.5 69932.53
##
## Random effects:
## Formula: ~1 | net
## (Intercept) Residual
## StdDev: 0.01171863 0.02590365
##
## Variance function:
## Structure: Exponential of variance covariate
## Formula: ~absInStrT_sqrt
## Parameter estimates:
## expon
## 0.3022834
## Fixed effects: s_g_area_abs ~ (absInStrT_sqrt + absOutStrT_sqrt) * topo
## Value Std.Error DF t-value p-value
## (Intercept) 0.8853460 0.0009112107 35062 971.6151 0e+00
## absInStrT_sqrt -0.0503492 0.0007669552 35062 -65.6482 0e+00
## absOutStrT_sqrt 0.0320175 0.0004961047 35062 64.5379 0e+00
## topoBA -0.0049266 0.0013273744 2997 -3.7115 2e-04
## topoWS 0.0259321 0.0024126298 2997 10.7485 0e+00
## absInStrT_sqrt:topoBA 0.0250739 0.0009679783 35062 25.9033 0e+00
## absInStrT_sqrt:topoWS -0.0162802 0.0016384693 35062 -9.9362 0e+00
## absOutStrT_sqrt:topoBA -0.0127848 0.0005518471 35062 -23.1674 0e+00
## absOutStrT_sqrt:topoWS -0.0099013 0.0011082549 35062 -8.9341 0e+00
## Correlation:
## (Intr) abIST_ abOST_ topoBA topoWS aIST_:B aIST_:W
## absInStrT_sqrt -0.729
## absOutStrT_sqrt -0.830 0.725
## topoBA -0.686 0.501 0.570
## topoWS -0.378 0.275 0.314 0.259
## absInStrT_sqrt:topoBA 0.578 -0.792 -0.574 -0.788 -0.218
## absInStrT_sqrt:topoWS 0.341 -0.468 -0.339 -0.234 -0.791 0.371
## absOutStrT_sqrt:topoBA 0.746 -0.652 -0.899 -0.721 -0.282 0.698 0.305
## absOutStrT_sqrt:topoWS 0.372 -0.325 -0.448 -0.255 -0.923 0.257 0.774
## aOST_:B
## absInStrT_sqrt
## absOutStrT_sqrt
## topoBA
## topoWS
## absInStrT_sqrt:topoBA
## absInStrT_sqrt:topoWS
## absOutStrT_sqrt:topoBA
## absOutStrT_sqrt:topoWS 0.402
##
## Standardized Within-Group Residuals:
## Min Q1 Med Q3 Max
## -11.9506757 -0.2730630 0.1596294 0.5131784 3.9557226
##
## Number of Observations: 38068
## Number of Groups: 3000
r.squaredGLMM(lmeModel)
## R2m R2c
## [1,] 0.7550304 0.7966482
lmeModel <- lme(s_g_area_abs ~ absInStrT_sqrt + absOutStrT_sqrt + topo,
data = respondedGenes,
weights = varExp(form = ~absInStrT_sqrt),
random = ~1|net,
method = "ML")
summary(lmeModel)
## Linear mixed-effects model fit by maximum likelihood
## Data: respondedGenes
## AIC BIC logLik
## -135245.9 -135177.6 67630.97
##
## Random effects:
## Formula: ~1 | net
## (Intercept) Residual
## StdDev: 0.01110035 0.02744975
##
## Variance function:
## Structure: Exponential of variance covariate
## Formula: ~absInStrT_sqrt
## Parameter estimates:
## expon
## 0.3081334
## Fixed effects: s_g_area_abs ~ absInStrT_sqrt + absOutStrT_sqrt + topo
## Value Std.Error DF t-value p-value
## (Intercept) 0.8985857 0.0006053751 35066 1484.3453 0
## absInStrT_sqrt -0.0446852 0.0004582699 35066 -97.5086 0
## absOutStrT_sqrt 0.0192030 0.0002215185 35066 86.6881 0
## topoBA 0.0074859 0.0007470849 2997 10.0201 0
## topoWS 0.0123497 0.0008610380 2997 14.3428 0
## Correlation:
## (Intr) abIST_ abOST_ topoBA
## absInStrT_sqrt -0.532
## absOutStrT_sqrt -0.592 0.685
## topoBA -0.304 -0.466 -0.202
## topoWS -0.351 -0.086 -0.149 0.373
##
## Standardized Within-Group Residuals:
## Min Q1 Med Q3 Max
## -11.8196000 -0.3056556 0.1819094 0.5754314 3.4794407
##
## Number of Observations: 38068
## Number of Groups: 3000
r.squaredGLMM(lmeModel)
## R2m R2c
## [1,] 0.7321321 0.7697799
# subset
ave_evolMetricsColnames_ofInterest <- c("ave_varP_1", "ave_relDeltaVar_10000", "ave_s_g_area_abs")
# There are also "num_generations", "num_nodes", "dens", "pop_size" columns, but they are identical for all topos.
# global net metrics
globalMetrics_forCorrs_sel <- netSelResults[, c(ave_evolMetricsColnames_ofInterest, globalNetMetricsColnames)]
globalMetrics_forCorrs_neu <- netSelResults[, c(ave_evolMetricsColnames_ofInterest, globalNetMetricsColnames)]
# gene-specific metrics
geneMetrics_forCorrs_sel <- selResults[, c(evolMetricsColnames_ofInterest, geneSpecificNetMetricsColnames_ofInterest)]
geneMetrics_forCorrs_neu <- neutrResults[, c(evolMetricsColnames_ofInterest, geneSpecificNetMetricsColnames_ofInterest)]
# selection
geneSpecificCorrs_sel <- rcorr(as.matrix(geneMetrics_forCorrs_sel), type = "spearman")
# neutrality
geneSpecificCorrs_neu <- rcorr(as.matrix(geneMetrics_forCorrs_neu), type = "spearman")
png(filename = paste0(pathToPlotsFolder, "/correlations_geneMetrics_sel.png"),
width = 25, height = 25, units = 'cm', res = 300)
corrplot(geneSpecificCorrs_sel$r, type = "upper", method = "color", diag = FALSE, addCoef.col = "black",
number.cex = 0.7,
p.mat = geneSpecificCorrs_sel$P, sig.level = 0.05, insig = "blank",
tl.col = "black", na.label = "NA", tl.srt = 45, col = brewer.pal(n = 8, name = "RdBu"), outline = TRUE, mar=c(0,0,1,0))
dev.off()
## png
## 2
tiff(filename = paste0(pathToPlotsFolder, "/correlations_geneMetrics_sel.tiff"),
width = 25, height = 25, units = 'cm', res = 300)
corrplot(geneSpecificCorrs_sel$r, type = "upper", method = "color", diag = FALSE, addCoef.col = "black",
number.cex = 0.7,
p.mat = geneSpecificCorrs_sel$P, sig.level = 0.05, insig = "blank",
tl.col = "black", na.label = "NA", tl.srt = 45, col = brewer.pal(n = 8, name = "RdBu"), outline = TRUE, mar=c(0,0,1,0))
dev.off()
## png
## 2
png(filename = paste0(pathToPlotsFolder, "/correlations_geneMetrics_neu.png"),
width = 25, height = 25, units = 'cm', res = 300)
corrplot(geneSpecificCorrs_neu$r, type = "upper", method = "color", diag = FALSE, addCoef.col = "black",
number.cex = 0.7,
p.mat = geneSpecificCorrs_neu$P, sig.level = 0.05, insig = "blank",
tl.col = "black", na.label = "NA", tl.srt = 45, col = brewer.pal(n = 8, name = "RdBu"), outline = TRUE, mar=c(0,0,1,0))
dev.off()
## png
## 2
tiff(filename = paste0(pathToPlotsFolder, "/correlations_geneMetrics_neu.tiff"),
width = 25, height = 25, units = 'cm', res = 300)
corrplot(geneSpecificCorrs_neu$r, type = "upper", method = "color", diag = FALSE, addCoef.col = "black",
number.cex = 0.7,
p.mat = geneSpecificCorrs_neu$P, sig.level = 0.05, insig = "blank",
tl.col = "black", na.label = "NA", tl.srt = 45, col = brewer.pal(n = 8, name = "RdBu"), outline = TRUE, mar=c(0,0,1,0))
dev.off()
## png
## 2
# selection
globalCorrs_sel <- rcorr(as.matrix(globalMetrics_forCorrs_sel), type = "spearman")
# neutrality
globalCorrs_neu <- rcorr(as.matrix(globalMetrics_forCorrs_neu), type = "spearman")
png(filename = paste0(pathToPlotsFolder, "/correlations_globalMetrics_sel.png"),
width = 20, height = 20, units = 'cm', res = 300)
corrplot(globalCorrs_sel$r, type = "upper", method = "color", diag = FALSE, addCoef.col = "black",
number.cex = 0.8,
p.mat = globalCorrs_sel$P, sig.level = 0.05, insig = "blank",
tl.col = "black", na.label = "NA", tl.srt = 45, col = brewer.pal(n = 8, name = "RdBu"), outline = TRUE, mar=c(0,0,1,0))
dev.off()
## png
## 2
tiff(filename = paste0(pathToPlotsFolder, "/correlations_globalMetrics_sel.tiff"),
width = 20, height = 20, units = 'cm', res = 300)
corrplot(globalCorrs_sel$r, type = "upper", method = "color", diag = FALSE, addCoef.col = "black",
number.cex = 0.8,
p.mat = globalCorrs_sel$P, sig.level = 0.05, insig = "blank",
tl.col = "black", na.label = "NA", tl.srt = 45, col = brewer.pal(n = 8, name = "RdBu"), outline = TRUE, mar=c(0,0,1,0))
dev.off()
## png
## 2
png(filename = paste0(pathToPlotsFolder, "/correlations_globalMetrics_neu.png"),
width = 20, height = 20, units = 'cm', res = 300)
corrplot(globalCorrs_neu$r, type = "upper", method = "color", diag = FALSE, addCoef.col = "black",
number.cex = 0.8,
p.mat = globalCorrs_neu$P, sig.level = 0.05, insig = "blank",
tl.col = "black", na.label = "NA", tl.srt = 45, col = brewer.pal(n = 8, name = "RdBu"), outline = TRUE, mar=c(0,0,1,0))
dev.off()
## png
## 2
tiff(filename = paste0(pathToPlotsFolder, "/correlations_globalMetrics_neu.tiff"),
width = 20, height = 20, units = 'cm', res = 300)
corrplot(globalCorrs_neu$r, type = "upper", method = "color", diag = FALSE, addCoef.col = "black",
number.cex = 0.8,
p.mat = globalCorrs_neu$P, sig.level = 0.05, insig = "blank",
tl.col = "black", na.label = "NA", tl.srt = 45, col = brewer.pal(n = 8, name = "RdBu"), outline = TRUE, mar=c(0,0,1,0))
dev.off()
## png
## 2
globalMetrics_forPCA <- netAllResults[, globalNetMetricsColnames]
colnames(globalMetrics_forPCA) <- c("diameter", "mean path distance", "degree assortativity", "degree centralization",
"indegree centralization", "outdegree centralization", "closeness centralization",
"betweenness centralization", "average degree", "average indegree", "average outdegree")
dudi <- dudi.pca(globalMetrics_forPCA, center = TRUE, scale = TRUE, nf = 10, scannf = FALSE)
plot_biplot <- fviz_pca_biplot(dudi,
geom.ind = "point",
col.ind = netAllResults$topo,
col.var = "black",
repel = TRUE,
addEllipses = TRUE,
legend.title = "Topology") +
scale_colour_manual(values = topoColors)
plot_biplot
plot_scree <- fviz_eig(dudi, addlabels = TRUE)
plot_corCircle <- fviz_pca_var(dudi, col.var = "contrib", labelsize = 4, repel = TRUE) +
scale_color_gradient2(low = "white", mid = "blue", high = "black")
plot_PCA <- plot_grid(plot_scree, plot_corCircle,
scale = c(0.95, 0.95),
labels = "AUTO",
label_size = 20,
label_fontface = "bold",
ncol = 2)
ggsave(filename = sprintf("plot_PCA.png"),
plot = plot_PCA,
path = pathToPlotsFolder, bg = 'white',
device = "png", scale = 2, width = 18, height = 9, units = "cm",
dpi = 300, limitsize = TRUE)
ggsave(filename = sprintf("plot_PCA.tiff"),
plot = plot_PCA,
path = pathToPlotsFolder, bg = 'white',
device = "tiff", scale = 2, width = 18, height = 9, units = "cm",
dpi = 300, limitsize = TRUE)
netAllResults$PC1<- -dudi$li$Axis1
netAllResults$PC2<- -dudi$li$Axis2
ave_responseToSel <- netSelResults$ave_responseToSel
netSelResults <- netAllResults[netAllResults$scen == "sel", ]
netSelResults$ave_responseToSel <- ave_responseToSel
netNeuResults <- netAllResults[netAllResults$scen == "neu", ]
# just selection
plot_PC1_topos <- ggplot(netSelResults, aes(y = PC1, x = topo)) +
geom_violin(fill = noiseColor, color = "black", trim = TRUE) +
geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label = round(..y.., digits = 3))) +
stat_compare_means(comparisons = my_comparisons, label = "p.signif") +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
labs(x = "Network topology",
y = expression(bold("PC1 (diameter + centralization)")))
plot_PC1_topos
plot_PC2_topos <- ggplot(netSelResults, aes(y = PC2, x = topo)) +
geom_violin(fill = noiseColor, color = "black", trim = TRUE) +
geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label = round(..y.., digits = 3))) +
stat_compare_means(comparisons = my_comparisons, label = "p.signif") +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
labs(x = "Network topology",
y = expression(bold("PC2 (average degree)")))
plot_PC2_topos
plot_netMetric <- ggplot(netSelResults, aes(y = diam, x = topo)) +
geom_violin(fill = noiseColor, color = "black", trim = TRUE) +
geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label = round(..y.., digits = 3))) +
stat_compare_means(comparisons = my_comparisons, label = "p.signif") +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
labs(x = "Network topology",
y = expression(bold("Diameter")))
plot_netMetric
plot_netMetric <- ggplot(netSelResults, aes(y = cntr_indegr, x = topo)) +
geom_violin(fill = noiseColor, color = "black", trim = TRUE) +
geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label = round(..y.., digits = 3))) +
stat_compare_means(comparisons = my_comparisons, label = "p.signif") +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
labs(x = "Network topology",
y = expression(bold("Indegree centralization")))
plot_netMetric
plot_netMetric <- ggplot(netSelResults, aes(y = cntr_outdegr, x = topo)) +
geom_violin(fill = noiseColor, color = "black", trim = TRUE) +
geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label = round(..y.., digits = 3))) +
stat_compare_means(comparisons = my_comparisons, label = "p.signif") +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
labs(x = "Network topology",
y = expression(bold("Outdegree centralization")))
plot_netMetric
plot_netMetric <- ggplot(netSelResults, aes(y = ave_k_all_inclps, x = topo)) +
geom_violin(fill = noiseColor, color = "black", trim = TRUE) +
geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label = round(..y.., digits = 3))) +
stat_compare_means(comparisons = my_comparisons, label = "p.signif") +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
labs(x = "Network topology",
y = expression(bold("Average degree")))
plot_netMetric
plot_netMetric <- ggplot(netSelResults, aes(y = ave_k_in_inclps, x = topo)) +
geom_violin(fill = noiseColor, color = "black", trim = TRUE) +
geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label = round(..y.., digits = 3))) +
stat_compare_means(comparisons = my_comparisons, label = "p.signif") +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
labs(x = "Network topology",
y = expression(bold("Average indegree")))
plot_netMetric
plot_netMetric <- ggplot(netSelResults, aes(y = ave_k_out_inclps, x = topo)) +
geom_violin(fill = noiseColor, color = "black", trim = TRUE) +
geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
hjust = 1.25, vjust = -2, color = "black", aes(label = round(..y.., digits = 3))) +
stat_compare_means(comparisons = my_comparisons, label = "p.signif") +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
scale_fill_manual(values = c("sel" = noiseColor, "neutr" = noiseColor)) +
labs(x = "Network topology",
y = expression(bold("Average outdegree")))
plot_netMetric
lmModel <- lm(ave_responseToSel ~ PC1 + PC2,
data = netSelResults)
summary(lmModel)
##
## Call:
## lm(formula = ave_responseToSel ~ PC1 + PC2, data = netSelResults)
##
## Residuals:
## Min 1Q Median 3Q Max
## -19.755 -1.756 -0.052 1.917 11.126
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 12.68933 0.05759 220.35 <2e-16 ***
## PC1 -3.28148 0.02313 -141.85 <2e-16 ***
## PC2 -2.59997 0.03217 -80.81 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.154 on 2997 degrees of freedom
## Multiple R-squared: 0.8989, Adjusted R-squared: 0.8989
## F-statistic: 1.333e+04 on 2 and 2997 DF, p-value: < 2.2e-16
plot_PC1 <- ggplot(netSelResults, aes(y = ave_responseToSel, x = PC1)) +
geom_point(aes(shape = topo, color = topo), alpha = 0.3, size = 2)+
geom_abline(slope = lmModel$coefficients[2],
intercept = lmModel$coefficients[1],
color = "black", linetype = "dashed", size = 1) +
theme_bw() +
theme(plot.title = element_text(size=12, face="bold",),
plot.subtitle = element_text(size=12, face="bold"),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "right") +
scale_colour_manual(values = topoColors) +
labs(x = expression(bold("PC1 (diameter + centralization)")),
y = expression(paste(bold("Average # responded genes"))))
plot_PC1
plot_PC2 <- ggplot(netSelResults, aes(y = ave_responseToSel, x = PC2)) +
geom_point(aes(shape = topo, color = topo), alpha = 0.3, size = 2)+
geom_abline(slope = lmModel$coefficients[3],
intercept = lmModel$coefficients[1],
color = "black", linetype = "dashed", size = 1) +
theme_bw() +
theme(plot.title = element_text(size=12, face="bold",),
plot.subtitle = element_text(size=12, face="bold"),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "right") +
scale_colour_manual(values = topoColors) +
labs(x = expression(bold("PC2 (average degree)")),
y = expression(paste(bold("Average # responded genes"))))
plot_PC2
# just selection
numResponded <- table(selResults$topo, selResults$responseToSel)
numResponded
##
## FALSE TRUE
## ER 869 9841
## BA 2152 25485
## WS 580 2742
numTopos <- as.vector(table(selResults$topo))
numResponded[, 2]/numTopos
## ER BA WS
## 0.9188609 0.9221334 0.8254064
#plot_numRespondedGenes <- ggplot(respondedGenes, aes(y = , x = topo)) +
# geom_violin(fill = genotypeColor, color = "black", trim = TRUE) +
# geom_boxplot(width = 0.1, alpha = 1, outlier.alpha = 0, fill = "white") +
# stat_summary(fun = mean, geom = "text", show.legend = FALSE, size = 5,
# hjust = 1.25, vjust = 3, color = "black", aes(label = round(..y.., digits = 3))) +
# stat_compare_means(comparisons = my_comparisons, label = "p.signif", method = "wilcox.test") +
# theme_pubclean() +
# theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
# axis.title.x = element_text(size=16, face="bold"),
# axis.title.y = element_text(size=16, face="bold"),
# axis.text.x = element_text(size=10, face="bold"),
# axis.text.y = element_text(size=10, face="bold")) +
# scale_fill_manual(values = c("sel" = genotypeColor, "neutr" = genotypeColor)) +
# labs(x = "Network topology",
# y = expression(paste(bold("Selective pressure "), "|", bold(p), "|")))
#plot_numRespondedGenes
#ggsave(filename = sprintf("plot_numRespondedGenes.png"),
# plot = plot_numRespondedGenes,
# device = "png", scale = 2, width = 6, height = 5.5, units = "cm",
# dpi = 300, limitsize = TRUE)
numPermutations = 10000
binNum = 30
# observed MI
obs_MI_PC1 <- calcInformation(netSelResults$ave_varP_1,
netSelResults$PC1, binNum)
obs_MI_PC2 <- calcInformation(netSelResults$ave_varP_1,
netSelResults$PC2, binNum)
# create MI null distributions from permutations
MI_nullDistr_PC1 <- vector(mode = "numeric", length = numPermutations)
MI_nullDistr_PC2 <- vector(mode = "numeric", length = numPermutations)
for(permNum in 1:numPermutations)
{
MI_nullDistr_PC1[permNum] <-
calcInformation(netSelResults$ave_varP_1,
sample(netSelResults$PC1,
size = length(netSelResults$PC1)),
binNum)
MI_nullDistr_PC2[permNum] <-
calcInformation(netSelResults$ave_varP_1,
sample(netSelResults$PC2,
size = length(netSelResults$PC2)),
binNum)
}
# pvals for observed MI and R
pval_MI_absInStrT <-
(length(which(MI_nullDistr_PC1 > obs_MI_PC1)) + 1)/numPermutations
pval_MI_absOutStrT <-
(length(which(MI_nullDistr_PC2 > obs_MI_PC2)) + 1)/numPermutations
# pvals for observed MI and R
pval_MI_absInStrT <-
(length(which(MI_nullDistr_PC1 > obs_MI_PC1)) + 1)/numPermutations
pval_MI_absOutStrT <-
(length(which(MI_nullDistr_PC2 > obs_MI_PC2)) + 1)/numPermutations
# title
if(pval_MI_absInStrT == 1e-04) {
MI_obs_explVar1_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC1, digits = 2), "; p $\\leq$ 10^{-4}"))
} else {
MI_obs_explVar1_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC1, digits = 2), "; p = ", round(pval_MI_absInStrT, digits = 2)))
}
if(pval_MI_absOutStrT == 1e-04) {
MI_obs_explVar2_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC2, digits = 2), "; p $\\leq$ 10^{-4}"))
} else {
MI_obs_explVar2_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC2, digits = 2), "; p = ", round(pval_MI_absOutStrT, digits = 2)))
}
# write MI and p values to text file
sink(paste0("../results/", jointResultsFolder, "/infoMeasures_ave_varP_1-PCs.txt"))
cat(paste0("Variables: ave_varP_1; PC1\n",
"Observed MI: ", obs_MI_PC1, "; pval: ", pval_MI_absInStrT, "\n",
"Variables: ave_varP_1; PC2\n",
"Observed MI: ", obs_MI_PC2, "; pval: ", pval_MI_absOutStrT, "\n"))
## Variables: ave_varP_1; PC1
## Observed MI: 0.344021032480232; pval: 1e-04
## Variables: ave_varP_1; PC2
## Observed MI: 0.341538656614752; pval: 1e-04
sink()
lmModel <- lm(ave_varP_1 ~ PC1 + PC2,
data = netSelResults)
summary(lmModel)
##
## Call:
## lm(formula = ave_varP_1 ~ PC1 + PC2, data = netSelResults)
##
## Residuals:
## Min 1Q Median 3Q Max
## -307.03 -97.03 -18.56 75.66 799.25
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 327.448 2.758 118.715 < 2e-16 ***
## PC1 -21.334 1.108 -19.254 < 2e-16 ***
## PC2 11.455 1.541 7.433 1.37e-13 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 151.1 on 2997 degrees of freedom
## Multiple R-squared: 0.1244, Adjusted R-squared: 0.1239
## F-statistic: 213 on 2 and 2997 DF, p-value: < 2.2e-16
r.squaredGLMM(lmModel)
## R2m R2c
## [1,] 0.1243734 0.1243734
# partial R^2
library(rstatix)
partial_R2_PC1 <- partial_eta_squared(lmModel)[1]
partial_R2_PC2 <- partial_eta_squared(lmModel)[2]
# R2m for plotting
partial_R2m_absInStr_num <- round(partial_R2_PC1, digits = 2)
partial_R2m_absOutStr_num <- round(partial_R2_PC2, digits = 2)
R2m_absInStr_text <- TeX(paste0("partial R^{2} = ", partial_R2m_absInStr_num))
R2m_absOutStr_text <- TeX(paste0("partial R^{2} = ", partial_R2m_absOutStr_num))
# get fitted coefficients from the model fit
coef_explVar1 <- signif(summary(lmModel)$coefficients[2, 1], digits = 2)
coef_explVar2 <- signif(summary(lmModel)$coefficients[3, 1], digits = 3)
# get p values from the model fit
pval_explVar1 <- signif(summary(lmModel)$coefficients[2, 4], digits = 2)
pval_explVar2 <- signif(summary(lmModel)$coefficients[3, 4], digits = 2)
# double check that the p values are zero before renaming them
if(summary(lmModel)$coefficients[2, 4] < 2.2e-16){pval_coef1_title = "p < 2.2 x 10^{-16}"} else
{pval_coef1_title = paste0("p = ", pval_explVar1)}
if(summary(lmModel)$coefficients[3, 4] < 2.2e-16){pval_coef2_title = "p < 2.2 x 10^{-16}"} else
{pval_coef2_title = paste0("p = ", pval_explVar2)}
coef_pval_explVar1_title <- TeX(paste0("$\\beta$ = ", coef_explVar1, "; ", pval_coef1_title))
coef_pval_explVar2_title <- TeX(paste0("$\\beta$ = ", coef_explVar2, "; ", pval_coef2_title))
plot_PC1 <- ggplot(netSelResults, aes(y = ave_varP_1, x = PC1)) +
geom_point(aes(shape = topo, color = topo), alpha = 0.3, size = 2)+
geom_abline(slope = lmModel$coefficients[2],
intercept = lmModel$coefficients[1],
color = "black", linetype = "dashed", size = 1) +
theme_bw() +
theme(plot.title = element_text(size=12, face="bold",),
plot.subtitle = element_text(size=12, face="bold"),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "right") +
scale_colour_manual(values = topoColors) +
labs(x = expression(bold("PC1 (diameter + centralization)")),
y = expression(paste(bold("Expression variance, gen. 1"))),
title = coef_pval_explVar1_title,
subtitle = R2m_absInStr_text,
color = "Topology",
shape = "Topology") +
annotate('text', x = -3, y = 750, label = MI_obs_explVar1_title_with_pval, parse = TRUE, size = 4, hjust = 0)
plot_PC1
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
plot_PC2 <- ggplot(netSelResults, aes(y = ave_varP_1, x = PC2)) +
geom_point(aes(shape = topo, color = topo), alpha = 0.3, size = 2)+
geom_abline(slope = lmModel$coefficients[3],
intercept = lmModel$coefficients[1],
color = "black", linetype = "dashed", size = 1) +
theme_bw() +
theme(plot.title = element_text(size=12, face="bold",),
plot.subtitle = element_text(size=12, face="bold"),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "right") +
scale_colour_manual(values = topoColors) +
labs(x = expression(bold("PC2 (average degree)")),
y = expression(paste(bold("Expression variance, gen. 1"))),
title = coef_pval_explVar2_title,
subtitle = R2m_absOutStr_text,
color = "Topology",
shape = "Topology") +
annotate('text', x = -3, y = 750, label = MI_obs_explVar2_title_with_pval, parse = TRUE, size = 4, hjust = 0)
plot_PC2
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
plot_netPropertiesFigure <- plot_grid(plot_PC1, plot_PC2,
labels = "AUTO",
label_size = 20,
label_fontface = "bold")
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
ggsave(filename = sprintf("plot_netPropertiesFigure_averageExprVar.png"),
plot = plot_netPropertiesFigure,
bg = "white",
path = pathToPlotsFolder,
device = "png",
scale = 2, height = 800, width = 1500, units = "px",
dpi = 300, limitsize = TRUE)
ggsave(filename = sprintf("plot_netPropertiesFigure_averageExprVar.tiff"),
plot = plot_netPropertiesFigure,
bg = "white",
path = pathToPlotsFolder,
device = "tiff",
scale = 2, height = 800, width = 1500, units = "px",
dpi = 300, limitsize = TRUE)
numPermutations = 10000
binNum = 30
# observed MI
obs_MI_PC1 <- calcInformation(netSelResults$ave_relDeltaVar_10000,
netSelResults$PC1, binNum)
obs_MI_PC2 <- calcInformation(netSelResults$ave_relDeltaVar_10000,
netSelResults$PC2, binNum)
# create MI null distributions from permutations
MI_nullDistr_PC1 <- vector(mode = "numeric", length = numPermutations)
MI_nullDistr_PC2 <- vector(mode = "numeric", length = numPermutations)
for(permNum in 1:numPermutations)
{
MI_nullDistr_PC1[permNum] <-
calcInformation(netSelResults$ave_relDeltaVar_10000,
sample(netSelResults$PC1,
size = length(netSelResults$PC1)),
binNum)
MI_nullDistr_PC2[permNum] <-
calcInformation(netSelResults$ave_relDeltaVar_10000,
sample(netSelResults$PC2,
size = length(netSelResults$PC2)),
binNum)
}
# pvals for observed MI and R
pval_MI_absInStrT <-
(length(which(MI_nullDistr_PC1 > obs_MI_PC1)) + 1)/numPermutations
pval_MI_absOutStrT <-
(length(which(MI_nullDistr_PC2 > obs_MI_PC2)) + 1)/numPermutations
# pvals for observed MI and R
pval_MI_absInStrT <-
(length(which(MI_nullDistr_PC1 > obs_MI_PC1)) + 1)/numPermutations
pval_MI_absOutStrT <-
(length(which(MI_nullDistr_PC2 > obs_MI_PC2)) + 1)/numPermutations
# title
if(pval_MI_absInStrT == 1e-04) {
MI_obs_explVar1_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC1, digits = 2), "; p $\\leq$ 10^{-4}"))
} else {
MI_obs_explVar1_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC1, digits = 2), "; p = ", round(pval_MI_absInStrT, digits = 2)))
}
if(pval_MI_absOutStrT == 1e-04) {
MI_obs_explVar2_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC2, digits = 2), "; p $\\leq$ 10^{-4}"))
} else {
MI_obs_explVar2_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC2, digits = 2), "; p = ", round(pval_MI_absOutStrT, digits = 2)))
}
# write MI and p values to text file
sink(paste0("../results/", jointResultsFolder, "/infoMeasures_ave_relDeltaVar_10000-PCs.txt"))
cat(paste0("Variables: ave_relDeltaVar_10000; PC1\n",
"Observed MI: ", obs_MI_PC1, "; pval: ", pval_MI_absInStrT, "\n",
"Variables: ave_relDeltaVar_10000; PC2\n",
"Observed MI: ", obs_MI_PC2, "; pval: ", pval_MI_absOutStrT, "\n"))
## Variables: ave_relDeltaVar_10000; PC1
## Observed MI: 0.330528975236185; pval: 1e-04
## Variables: ave_relDeltaVar_10000; PC2
## Observed MI: 0.369918257229613; pval: 1e-04
sink()
lmModel <- lm(ave_relDeltaVar_10000 ~ PC1 + PC2,
data = netSelResults)
summary(lmModel)
##
## Call:
## lm(formula = ave_relDeltaVar_10000 ~ PC1 + PC2, data = netSelResults)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.06174 -0.01482 -0.00365 0.00704 0.51464
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.9180004 0.0006221 -1475.739 < 2e-16 ***
## PC1 0.0008091 0.0002500 3.237 0.00122 **
## PC2 -0.0046551 0.0003474 -13.399 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03401 on 2986 degrees of freedom
## (11 observations deleted due to missingness)
## Multiple R-squared: 0.05982, Adjusted R-squared: 0.05919
## F-statistic: 94.99 on 2 and 2986 DF, p-value: < 2.2e-16
r.squaredGLMM(lmModel)
## R2m R2c
## [1,] 0.05978133 0.05978133
# partial R^2
library(rstatix)
partial_R2_PC1 <- partial_eta_squared(lmModel)[1]
partial_R2_PC2 <- partial_eta_squared(lmModel)[2]
# R2m for plotting
partial_R2m_absInStr_num <- round(partial_R2_PC1, digits = 2)
partial_R2m_absOutStr_num <- round(partial_R2_PC2, digits = 2)
R2m_absInStr_text <- TeX(paste0("partial R^{2} = ", partial_R2m_absInStr_num))
R2m_absOutStr_text <- TeX(paste0("partial R^{2} = ", partial_R2m_absOutStr_num))
# get fitted coefficients from the model fit
coef_explVar1 <- signif(summary(lmModel)$coefficients[2, 1], digits = 2)
coef_explVar2 <- signif(summary(lmModel)$coefficients[3, 1], digits = 3)
#if(coef_explVar2 == -0.0096){coef_explVar2 = -0.009}
# get p values from the model fit
pval_explVar1 <- signif(summary(lmModel)$coefficients[2, 4], digits = 2)
pval_explVar2 <- signif(summary(lmModel)$coefficients[3, 4], digits = 2)
# double check that the p values are zero before renaming them
if(summary(lmModel)$coefficients[2, 4] < 2.2e-16){pval_coef1_title = "p < 2.2 x 10^{-16}"} else
{pval_coef1_title = paste0("p = ", pval_explVar1)}
if(summary(lmModel)$coefficients[3, 4] < 2.2e-16){pval_coef2_title = "p < 2.2 x 10^{-16}"} else
{pval_coef2_title = paste0("p = ", pval_explVar2)}
coef_pval_explVar1_title <- TeX(paste0("$\\beta$ = ", coef_explVar1, "; ", pval_coef1_title))
coef_pval_explVar2_title <- TeX(paste0("$\\beta$ = ", coef_explVar2, "; ", pval_coef2_title))
plot_PC1 <- ggplot(netSelResults, aes(y = ave_relDeltaVar_10000, x = PC1)) +
geom_point(aes(shape = topo, color = topo), alpha = 0.3, size = 2)+
geom_abline(slope = lmModel$coefficients[2],
intercept = lmModel$coefficients[1],
color = "black", linetype = "dashed", size = 1) +
theme_bw() +
theme(plot.title = element_text(size=12, face="bold",),
plot.subtitle = element_text(size=12, face="bold"),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "right") +
scale_colour_manual(values = topoColors) +
labs(x = expression(bold("PC1 (diameter + centralization)")),
y = expression(bold("Rel."~Delta~"expr. variance")),
title = coef_pval_explVar1_title,
subtitle = R2m_absInStr_text,
color = "Topology",
shape = "Topology") +
annotate('text', x = -4, y = -0.4, label = MI_obs_explVar1_title_with_pval, parse = TRUE, size = 4, hjust = 0)
plot_PC1
## Warning: Removed 11 rows containing missing values (geom_point).
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
plot_PC2 <- ggplot(netSelResults, aes(y = ave_relDeltaVar_10000, x = PC2)) +
geom_point(aes(shape = topo, color = topo), alpha = 0.3, size = 2)+
geom_abline(slope = lmModel$coefficients[3],
intercept = lmModel$coefficients[1],
color = "black", linetype = "dashed", size = 1) +
theme_bw() +
theme(plot.title = element_text(size=12, face="bold",),
plot.subtitle = element_text(size=12, face="bold"),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "right") +
scale_colour_manual(values = topoColors) +
labs(x = expression(bold("PC2 (average degree)")),
y = expression(bold("Rel."~Delta~"expr. variance")),
title = coef_pval_explVar2_title,
subtitle = R2m_absOutStr_text,
color = "Topology",
shape = "Topology") +
annotate('text', x = -3, y = -0.4, label = MI_obs_explVar2_title_with_pval, parse = TRUE, size = 4, hjust = 0)
plot_PC2
## Warning: Removed 11 rows containing missing values (geom_point).
## Warning: is.na() applied to non-(list or vector) of type 'expression'
plot_netPropertiesFigure <- plot_grid(plot_PC1, plot_PC2,
labels = "AUTO",
label_size = 20,
label_fontface = "bold")
## Warning: Removed 11 rows containing missing values (geom_point).
## Warning: is.na() applied to non-(list or vector) of type 'expression'
## Warning: Removed 11 rows containing missing values (geom_point).
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
ggsave(filename = sprintf("plot_netPropertiesFigure_averageRelDeltaVar.png"),
plot = plot_netPropertiesFigure,
bg = "white",
path = pathToPlotsFolder,
device = "png",
scale = 2, height = 800, width = 1500, units = "px",
dpi = 300, limitsize = TRUE)
ggsave(filename = sprintf("plot_netPropertiesFigure_averageRelDeltaVar.tiff"),
plot = plot_netPropertiesFigure,
bg = "white",
path = pathToPlotsFolder,
device = "tiff",
scale = 2, height = 800, width = 1500, units = "px",
dpi = 300, limitsize = TRUE)
lmeModel <- lm(ave_s_g_area_abs ~ PC1 + PC2,
data = netSelResults)
summary(lmeModel)
##
## Call:
## lm(formula = ave_s_g_area_abs ~ PC1 + PC2, data = netSelResults)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.51260 -0.04439 0.01975 0.06502 0.22053
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.7886234 0.0020192 390.562 < 2e-16 ***
## PC1 0.0031964 0.0008111 3.941 8.31e-05 ***
## PC2 -0.0130972 0.0011281 -11.610 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.1106 on 2997 degrees of freedom
## Multiple R-squared: 0.04776, Adjusted R-squared: 0.04713
## F-statistic: 75.16 on 2 and 2997 DF, p-value: < 2.2e-16
r.squaredGLMM(lmeModel)
## R2m R2c
## [1,] 0.04773057 0.04773057
numPermutations = 10000
binNum = 30
# observed MI
obs_MI_PC1 <- calcInformation(netNeuResults$ave_s_g_area_abs,
netNeuResults$PC1, binNum)
obs_MI_PC2 <- calcInformation(netNeuResults$ave_s_g_area_abs,
netNeuResults$PC2, binNum)
# create MI null distributions from permutations
MI_nullDistr_PC1 <- vector(mode = "numeric", length = numPermutations)
MI_nullDistr_PC2 <- vector(mode = "numeric", length = numPermutations)
for(permNum in 1:numPermutations)
{
MI_nullDistr_PC1[permNum] <-
calcInformation(netNeuResults$ave_s_g_area_abs,
sample(netNeuResults$PC1,
size = length(netNeuResults$PC1)),
binNum)
MI_nullDistr_PC2[permNum] <-
calcInformation(netNeuResults$ave_s_g_area_abs,
sample(netNeuResults$PC2,
size = length(netNeuResults$PC2)),
binNum)
}
# pvals for observed MI and R
pval_MI_absInStrT <-
(length(which(MI_nullDistr_PC1 > obs_MI_PC1)) + 1)/numPermutations
pval_MI_absOutStrT <-
(length(which(MI_nullDistr_PC2 > obs_MI_PC2)) + 1)/numPermutations
# pvals for observed MI and R
pval_MI_absInStrT <-
(length(which(MI_nullDistr_PC1 > obs_MI_PC1)) + 1)/numPermutations
pval_MI_absOutStrT <-
(length(which(MI_nullDistr_PC2 > obs_MI_PC2)) + 1)/numPermutations
# title
if(pval_MI_absInStrT == 1e-04) {
MI_obs_explVar1_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC1, digits = 2), "; p $\\leq$ 10^{-4}"))
} else {
MI_obs_explVar1_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC1, digits = 2), "; p = ", round(pval_MI_absInStrT, digits = 2)))
}
if(pval_MI_absOutStrT == 1e-04) {
MI_obs_explVar2_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC2, digits = 2), "; p $\\leq$ 10^{-4}"))
} else {
MI_obs_explVar2_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC2, digits = 2), "; p = ", round(pval_MI_absOutStrT, digits = 2)))
}
# write MI and p values to text file
sink(paste0("../results/", jointResultsFolder, "/infoMeasures_s_g_area_abs-PCs_neutrality.txt"))
cat(paste0("Variables: ave_s_g_area_abs; PC1\n",
"Observed MI: ", obs_MI_PC1, "; pval: ", pval_MI_absInStrT, "\n",
"Variables: ave_s_g_area_abs; PC2\n",
"Observed MI: ", obs_MI_PC2, "; pval: ", pval_MI_absOutStrT, "\n"))
## Variables: ave_s_g_area_abs; PC1
## Observed MI: 0.278380815510643; pval: 1e-04
## Variables: ave_s_g_area_abs; PC2
## Observed MI: 0.280293215696524; pval: 1e-04
sink()
plot_hist_MI_obs_PC1 <- ggplot(data = data.frame(MI = MI_nullDistr_PC1), aes(x = MI)) +
geom_histogram(fill = MIColor, color = MIColor, bins = 50, alpha = 0.5) +
geom_vline(xintercept = obs_MI_PC1, col = MIColor, lwd = 2, lty = 2) +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
labs(x = expression(paste(bold("Mutual Information (PC1)"))), y = "count",
title = MI_obs_explVar1_title_with_pval) +
annotate('text', x = obs_MI_PC1, y = Inf, label = "obs", parse = TRUE, size = 4, vjust = 3, hjust = 1.5)
plot_hist_MI_obs_PC1
ggsave(filename = sprintf("plot_hist_MI_obs_PC1_neu.png"),
path = pathToPlotsFolder,
plot = plot_hist_MI_obs_PC1,
device = "png", scale = 2, width = 6, height = 6, units = "cm",
dpi = 300, limitsize = TRUE)
plot_hist_MI_obs_PC2 <- ggplot(data = data.frame(MI = MI_nullDistr_PC2), aes(x = MI)) +
geom_histogram(fill = MIColor, color = MIColor, bins = 50, alpha = 0.5) +
geom_vline(xintercept = obs_MI_PC2, col = MIColor, lwd = 2, lty = 2) +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
labs(x = expression(paste(bold("Mutual Information (PC2)"))), y = "count",
title = MI_obs_explVar2_title_with_pval) +
annotate('text', x = obs_MI_PC2, y = Inf, label = "obs", parse = TRUE, size = 4, vjust = 3, hjust = 1.5)
plot_hist_MI_obs_PC2
ggsave(filename = sprintf("plot_hist_MI_obs_PC2_neu.png"),
path = pathToPlotsFolder,
plot = plot_hist_MI_obs_PC2,
device = "png", scale = 2, width = 6, height = 6, units = "cm",
dpi = 300, limitsize = TRUE)
indeptest <- function(model) {
return(Box.test(resid(model)[order(fitted(model))], type = "Ljung-Box"))
}
lmModel <- lm(ave_s_g_area_abs ~ PC1 + PC2,
data = netNeuResults)
summary(lmModel)
##
## Call:
## lm(formula = ave_s_g_area_abs ~ PC1 + PC2, data = netNeuResults)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.0061157 -0.0007579 -0.0000013 0.0007506 0.0079375
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.108e-03 2.635e-05 269.738 <2e-16 ***
## PC1 4.525e-06 1.059e-05 0.427 0.669
## PC2 1.124e-07 1.472e-05 0.008 0.994
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.001443 on 2997 degrees of freedom
## Multiple R-squared: 6.099e-05, Adjusted R-squared: -0.0006063
## F-statistic: 0.0914 on 2 and 2997 DF, p-value: 0.9127
r.squaredGLMM(lmModel)
## R2m R2c
## [1,] 6.095047e-05 6.095047e-05
vif(lmModel)
## PC1 PC2
## 1 1
shapiro.test(lmModel[['residuals']])
##
## Shapiro-Wilk normality test
##
## data: lmModel[["residuals"]]
## W = 0.96847, p-value < 2.2e-16
indeptest(lmModel)
##
## Box-Ljung test
##
## data: resid(model)[order(fitted(model))]
## X-squared = 0.8294, df = 1, p-value = 0.3624
partial_eta_squared(lmModel)
## PC1 PC2
## 6.097171e-05 1.943916e-08
# partial R^2
partial_R2_PC1 <- partial_eta_squared(lmModel)[1]
partial_R2_PC2 <- partial_eta_squared(lmModel)[2]
# R2m for plotting
partial_R2m_absInStr_num <- signif(partial_R2_PC1, digits = 2)
partial_R2m_absOutStr_num <- signif(partial_R2_PC2, digits = 2)
if(partial_R2m_absInStr_num == 1.5e-06){partial_R2m_absInStr_num = "1.5 x 10^{-6}"}
if(partial_R2m_absOutStr_num == 9.8e-08){partial_R2m_absOutStr_num = "9.8 x 10^{-8}"}
R2m_absInStr_text <- TeX(paste0("partial R^{2} = ", partial_R2m_absInStr_num))
R2m_absOutStr_text <- TeX(paste0("partial R^{2} = ", partial_R2m_absOutStr_num))
# get fitted coefficients from the model fit
coef_explVar1 <- signif(summary(lmModel)$coefficients[2, 1], digits = 2)
coef_explVar2 <- signif(summary(lmModel)$coefficients[3, 1], digits = 2)
if(coef_explVar1 == -2.8e-07){coef_explVar1 = "-2.8 x 10^{-7}"}
if(coef_explVar2 == -1e-07){coef_explVar2 = "-1 x 10^{-7}"}
# get p values from the model fit
pval_explVar1 <- signif(summary(lmModel)$coefficients[2, 4], digits = 2)
pval_explVar2 <- signif(summary(lmModel)$coefficients[3, 4], digits = 2)
# double check that the p values are zero before renaming them
if(summary(lmModel)$coefficients[2, 4] < 2.2e-16){pval_coef1_title = "p < 2.2 x 10^{-16}"} else
{pval_coef1_title = paste0("p = ", pval_explVar1)}
if(summary(lmModel)$coefficients[3, 4] < 2.2e-16){pval_coef2_title = "p < 2.2 x 10^{-16}"} else
{pval_coef2_title = paste0("p = ", pval_explVar2)}
coef_pval_explVar1_title <- TeX(paste0("$\\beta$ = ", coef_explVar1, "; ", pval_coef1_title))
coef_pval_explVar2_title <- TeX(paste0("$\\beta$ = ", coef_explVar2, "; ", pval_coef2_title))
plot_constVar_resid <- ggplot(data = data.frame("Fitted_values" = fitted(lmModel),
"Pearsons_residuals" = resid(lmModel, type = "pearson")),
aes(x = Fitted_values, y = Pearsons_residuals)) +
geom_point(alpha = 0.2, size = 0.5) +
theme_bw() +
theme(plot.title = element_text(size=8, face="bold", hjust = 0.5),
axis.title.x = element_text(size=8, face="bold"),
axis.title.y = element_text(size=8, face="bold"),
axis.text.x = element_text(size=6, face="bold"),
axis.text.y = element_text(size=6, face="bold")) +
annotate("label", x = 0.0070775, y = 0.0015, label = "Neutrality", size = 3) +
labs(x = "Fitted values", y = "Pearson's residuals")
plot_constVar_qqResid <- ggplot(data = data.frame("Pearsons_residuals" = resid(lmModel, type = "pearson")),
aes(sample = Pearsons_residuals)) +
stat_qq(alpha = 0.2, size = 0.5) + stat_qq_line() +
theme_bw() +
theme(plot.title = element_text(size=8, face="bold", hjust = 0.5),
axis.title.x = element_text(size=8, face="bold"),
axis.title.y = element_text(size=8, face="bold"),
axis.text.x = element_text(size=6, face="bold"),
axis.text.y = element_text(size=6, face="bold")) +
labs(x = "Theoretical quantiles", y = "Sample quantiles",
title = "Normal Q-Q plot, residuals")
plot_constVar_resid
plot_constVar_qqResid
plot_PC1_selpress_neu <- ggplot(netNeuResults, aes(y = ave_s_g_area_abs, x = PC1)) +
geom_point(aes(shape = topo, color = topo), alpha = 0.3, size = 2)+
theme_bw() +
theme(plot.title = element_text(size=12, face="bold",),
plot.subtitle = element_text(size=12, face="bold"),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "bottom",
legend.title = element_text(size=12),
legend.text = element_text(size=12)) +
scale_colour_manual(values = topoColors,
labels = c("random (Erdős–Rényi)",
"scale-free (Barabási–Albert)",
"small-world (Watts–Strogatz)")) +
scale_shape_manual(values = c("ER" = 19, "BA" = 17, "WS" = 15),
labels = c("random (Erdős–Rényi)",
"scale-free (Barabási–Albert)",
"small-world (Watts–Strogatz)")) +
labs(x = expression(bold("PC1 (diameter + centralization)")),
y = expression(paste(bold("Average selective pressure "), "|", bold(p), "|")),
title = coef_pval_explVar1_title,
subtitle = R2m_absInStr_text,
color = "Topology",
shape = "Topology") +
annotate('text', x = -4, y = 0.95, label = MI_obs_explVar1_title_with_pval, parse = TRUE, size = 4, hjust = 0) +
ylim(0, 1)
plot_PC1_selpress_neu
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
plot_PC2_selpress_neu <- ggplot(netNeuResults, aes(y = ave_s_g_area_abs, x = PC2)) +
geom_point(aes(shape = topo, color = topo), alpha = 0.3, size = 2)+
theme_bw() +
theme(plot.title = element_text(size=12, face="bold",),
plot.subtitle = element_text(size=12, face="bold"),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "bottom",
legend.title = element_text(size=12),
legend.text = element_text(size=12)) +
scale_colour_manual(values = topoColors,
labels = c("random (Erdős–Rényi)",
"scale-free (Barabási–Albert)",
"small-world (Watts–Strogatz)")) +
scale_shape_manual(values = c("ER" = 19, "BA" = 17, "WS" = 15),
labels = c("random (Erdős–Rényi)",
"scale-free (Barabási–Albert)",
"small-world (Watts–Strogatz)")) +
labs(x = expression(bold("PC2 (average degree)")),
y = expression(paste(bold("Average selective pressure "), "|", bold(p), "|")),
title = coef_pval_explVar2_title,
subtitle = R2m_absOutStr_text,
color = "Topology",
shape = "Topology") +
annotate('text', x = -3, y = 0.95, label = MI_obs_explVar2_title_with_pval, parse = TRUE, size = 4, hjust = 0) +
scale_x_continuous(n.breaks = 4) +
ylim(0, 1)
plot_PC2_selpress_neu
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
numPermutations = 10000
binNum = 30
# observed MI
obs_MI_PC1 <- calcInformation(netSelResults$ave_s_g_area_abs,
netSelResults$PC1, binNum)
obs_MI_PC2 <- calcInformation(netSelResults$ave_s_g_area_abs,
netSelResults$PC2, binNum)
# create MI null distributions from permutations
MI_nullDistr_PC1 <- vector(mode = "numeric", length = numPermutations)
MI_nullDistr_PC2 <- vector(mode = "numeric", length = numPermutations)
for(permNum in 1:numPermutations)
{
MI_nullDistr_PC1[permNum] <-
calcInformation(netSelResults$ave_s_g_area_abs,
sample(netSelResults$PC1,
size = length(netSelResults$PC1)),
binNum)
MI_nullDistr_PC2[permNum] <-
calcInformation(netSelResults$ave_s_g_area_abs,
sample(netSelResults$PC2,
size = length(netSelResults$PC2)),
binNum)
}
# pvals for observed MI and R
pval_MI_absInStrT <-
(length(which(MI_nullDistr_PC1 > obs_MI_PC1)) + 1)/numPermutations
pval_MI_absOutStrT <-
(length(which(MI_nullDistr_PC2 > obs_MI_PC2)) + 1)/numPermutations
# pvals for observed MI and R
pval_MI_absInStrT <-
(length(which(MI_nullDistr_PC1 > obs_MI_PC1)) + 1)/numPermutations
pval_MI_absOutStrT <-
(length(which(MI_nullDistr_PC2 > obs_MI_PC2)) + 1)/numPermutations
# title
if(pval_MI_absInStrT == 1e-04) {
MI_obs_explVar1_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC1, digits = 2), "; p $\\leq$ 10^{-4}"))
} else {
MI_obs_explVar1_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC1, digits = 2), "; p = ", round(pval_MI_absInStrT, digits = 2)))
}
if(pval_MI_absOutStrT == 1e-04) {
MI_obs_explVar2_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC2, digits = 2), "; p $\\leq$ 10^{-4}"))
} else {
MI_obs_explVar2_title_with_pval <-
TeX(paste0("$\\MI$ = ", round(obs_MI_PC2, digits = 2), "; p = ", round(pval_MI_absOutStrT, digits = 2)))
}
# write MI and p values to text file
sink(paste0("../results/", jointResultsFolder, "/infoMeasures_s_g_area_abs-PCs.txt"))
cat(paste0("Variables: ave_s_g_area_abs; PC1\n",
"Observed MI: ", obs_MI_PC1, "; pval: ", pval_MI_absInStrT, "\n",
"Variables: ave_s_g_area_abs; PC2\n",
"Observed MI: ", obs_MI_PC2, "; pval: ", pval_MI_absOutStrT, "\n"))
## Variables: ave_s_g_area_abs; PC1
## Observed MI: 0.379681086586332; pval: 1e-04
## Variables: ave_s_g_area_abs; PC2
## Observed MI: 0.376520487406413; pval: 1e-04
sink()
plot_hist_MI_obs_PC1 <- ggplot(data = data.frame(MI = MI_nullDistr_PC1), aes(x = MI)) +
geom_histogram(fill = MIColor, color = MIColor, bins = 50, alpha = 0.5) +
geom_vline(xintercept = obs_MI_PC1, col = MIColor, lwd = 2, lty = 2) +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
labs(x = expression(paste(bold("Mutual Information (PC1)"))), y = "count",
title = MI_obs_explVar1_title_with_pval) +
annotate('text', x = obs_MI_PC1, y = Inf, label = "obs", parse = TRUE, size = 4, vjust = 3, hjust = 1.5)
plot_hist_MI_obs_PC1
ggsave(filename = sprintf("plot_hist_MI_obs_PC1_sel.png"),
path = pathToPlotsFolder,
plot = plot_hist_MI_obs_PC1,
device = "png", scale = 2, width = 6, height = 6, units = "cm",
dpi = 300, limitsize = TRUE)
plot_hist_MI_obs_PC2 <- ggplot(data = data.frame(MI = MI_nullDistr_PC2), aes(x = MI)) +
geom_histogram(fill = MIColor, color = MIColor, bins = 50, alpha = 0.5) +
geom_vline(xintercept = obs_MI_PC2, col = MIColor, lwd = 2, lty = 2) +
theme_pubclean() +
theme(plot.title = element_text(size=16, face="bold", hjust = 0.5),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold")) +
labs(x = expression(paste(bold("Mutual Information (PC2)"))), y = "count",
title = MI_obs_explVar2_title_with_pval) +
annotate('text', x = obs_MI_PC2, y = Inf, label = "obs", parse = TRUE, size = 4, vjust = 3, hjust = 1.5)
plot_hist_MI_obs_PC2
ggsave(filename = sprintf("plot_hist_MI_obs_PC2_sel.png"),
path = pathToPlotsFolder,
plot = plot_hist_MI_obs_PC2,
device = "png", scale = 2, width = 6, height = 6, units = "cm",
dpi = 300, limitsize = TRUE)
indeptest <- function(model) {
return(Box.test(resid(model)[order(fitted(model))], type = "Ljung-Box"))
}
lmModel <- lm(ave_s_g_area_abs ~ PC1 + PC2,
data = netSelResults)
summary(lmModel)
##
## Call:
## lm(formula = ave_s_g_area_abs ~ PC1 + PC2, data = netSelResults)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.51260 -0.04439 0.01975 0.06502 0.22053
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.7886234 0.0020192 390.562 < 2e-16 ***
## PC1 0.0031964 0.0008111 3.941 8.31e-05 ***
## PC2 -0.0130972 0.0011281 -11.610 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.1106 on 2997 degrees of freedom
## Multiple R-squared: 0.04776, Adjusted R-squared: 0.04713
## F-statistic: 75.16 on 2 and 2997 DF, p-value: < 2.2e-16
r.squaredGLMM(lmModel)
## R2m R2c
## [1,] 0.04773057 0.04773057
vif(lmModel)
## PC1 PC2
## 1 1
shapiro.test(lmModel[['residuals']])
##
## Shapiro-Wilk normality test
##
## data: lmModel[["residuals"]]
## W = 0.93391, p-value < 2.2e-16
indeptest(lmModel)
##
## Box-Ljung test
##
## data: resid(model)[order(fitted(model))]
## X-squared = 0.97813, df = 1, p-value = 0.3227
partial_eta_squared(lmModel)
## PC1 PC2
## 0.005154718 0.043039302
# partial R^2
partial_R2_PC1 <- partial_eta_squared(lmModel)[1]
partial_R2_PC2 <- partial_eta_squared(lmModel)[2]
# R2m for plotting
partial_R2m_absInStr_num <- round(partial_R2_PC1, digits = 2)
partial_R2m_absOutStr_num <- round(partial_R2_PC2, digits = 2)
R2m_absInStr_text <- TeX(paste0("partial R^{2} = ", partial_R2m_absInStr_num))
R2m_absOutStr_text <- TeX(paste0("partial R^{2} = ", partial_R2m_absOutStr_num))
# get fitted coefficients from the model fit
coef_explVar1 <- signif(summary(lmModel)$coefficients[2, 1], digits = 1)
coef_explVar2 <- signif(summary(lmModel)$coefficients[3, 1], digits = 2)
if(coef_explVar2 == -0.0096){coef_explVar2 = -0.009}
# get p values from the model fit
pval_explVar1 <- signif(summary(lmModel)$coefficients[2, 4], digits = 2)
pval_explVar2 <- signif(summary(lmModel)$coefficients[3, 4], digits = 2)
# double check that the p values are zero before renaming them
if(summary(lmModel)$coefficients[2, 4] < 2.2e-16){pval_coef1_title = "p < 2.2 x 10^{-16}"} else
{pval_coef1_title = paste0("p = ", pval_explVar1)}
if(summary(lmModel)$coefficients[3, 4] < 2.2e-16){pval_coef2_title = "p < 2.2 x 10^{-16}"} else
{pval_coef2_title = paste0("p = ", pval_explVar2)}
if(pval_explVar1 == 4.9e-11) {pval_coef1_title = paste0("p = 4.9 x 10^{-11}")}
coef_pval_explVar1_title <- TeX(paste0("$\\beta$ = ", coef_explVar1, "; ", pval_coef1_title))
coef_pval_explVar2_title <- TeX(paste0("$\\beta$ = ", coef_explVar2, "; ", pval_coef2_title))
plot_constVar_resid_sel <- ggplot(data = data.frame("Fitted_values" = fitted(lmModel),
"Pearsons_residuals" = resid(lmModel, type = "pearson")),
aes(x = Fitted_values, y = Pearsons_residuals)) +
geom_point(alpha = 0.2, size = 0.5) +
theme_bw() +
theme(plot.title = element_text(size=8, face="bold", hjust = 0.5),
axis.title.x = element_text(size=8, face="bold"),
axis.title.y = element_text(size=8, face="bold"),
axis.text.x = element_text(size=6, face="bold"),
axis.text.y = element_text(size=6, face="bold")) +
annotate("label", x = 0.75, y = -0.5, label = "Selection", size = 3) +
labs(x = "Fitted values", y = "Pearson's residuals")
plot_constVar_qqResid_sel <- ggplot(data = data.frame("Pearsons_residuals" = resid(lmModel, type = "pearson")),
aes(sample = Pearsons_residuals)) +
stat_qq(alpha = 0.2, size = 0.5) + stat_qq_line() +
theme_bw() +
theme(plot.title = element_text(size=8, face="bold", hjust = 0.5),
axis.title.x = element_text(size=8, face="bold"),
axis.title.y = element_text(size=8, face="bold"),
axis.text.x = element_text(size=6, face="bold"),
axis.text.y = element_text(size=6, face="bold")) +
labs(x = "Theoretical quantiles", y = "Sample quantiles",
title = "Normal Q-Q plot, residuals")
plot_constVar_resid_sel
plot_constVar_qqResid_sel
plot_ModelDiagnostics <- plot_grid(plot_constVar_resid_sel, plot_constVar_qqResid_sel,
plot_constVar_resid, plot_constVar_qqResid,
ncol = 2,
labels = "AUTO")
# save to plots folder
ggsave(filename = sprintf("plot_ModelDiagnostics_networkProperties.png"),
path = pathToPlotsFolder,
plot = plot_ModelDiagnostics,
device = "png", scale = 1.2, width = 12, height = 12, units = "cm",
dpi = 300, limitsize = TRUE,
bg = "white")
plot_PC1_selpress_sel <- ggplot(netSelResults, aes(y = ave_s_g_area_abs, x = PC1)) +
geom_point(aes(shape = topo, color = topo), alpha = 0.3, size = 2) +
geom_quantile(quantiles = c(.5), color = "black", size = 0.75) +
geom_quantile(quantiles = c(.25, .75), color = "black", size = 0.5, linetype = 2) +
theme_bw() +
theme(plot.title = element_text(size=12, face="bold",),
plot.subtitle = element_text(size=12, face="bold"),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "bottom",
legend.title = element_text(size=12),
legend.text = element_text(size=12)) +
scale_colour_manual(values = topoColors,
labels = c("random (Erdős–Rényi)",
"scale-free (Barabási–Albert)",
"small-world (Watts–Strogatz)")) +
scale_shape_manual(values = c("ER" = 19, "BA" = 17, "WS" = 15),
labels = c("random (Erdős–Rényi)",
"scale-free (Barabási–Albert)",
"small-world (Watts–Strogatz)")) +
labs(x = expression(bold("PC1 (diameter + centralization)")),
y = expression(paste(bold("Average selective pressure "), "|", bold(p), "|")),
title = coef_pval_explVar1_title,
subtitle = R2m_absInStr_text,
color = "Topology",
shape = "Topology") +
annotate('text', x = -4, y = 0.95, label = MI_obs_explVar1_title_with_pval, parse = TRUE, size = 4, hjust = 0) +
ylim(0, 1)
plot_PC1_selpress_sel
## Smoothing formula not specified. Using: y ~ x
## Smoothing formula not specified. Using: y ~ x
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
plot_PC2_selpress_sel <- ggplot(netSelResults, aes(y = ave_s_g_area_abs, x = PC2)) +
geom_point(aes(shape = topo, color = topo), alpha = 0.3, size = 2) +
geom_quantile(quantiles = c(.5), color = "black", size = 0.75) +
geom_quantile(quantiles = c(.25, .75), color = "black", size = 0.5, linetype = 2) +
theme_bw() +
theme(plot.title = element_text(size=12, face="bold",),
plot.subtitle = element_text(size=12, face="bold"),
axis.title.x = element_text(size=16, face="bold"),
axis.title.y = element_text(size=16, face="bold"),
axis.text.x = element_text(size=10, face="bold"),
axis.text.y = element_text(size=10, face="bold"),
legend.position = "bottom",
legend.title = element_text(size=12),
legend.text = element_text(size=12)) +
scale_colour_manual(values = topoColors,
labels = c("random (Erdős–Rényi)",
"scale-free (Barabási–Albert)",
"small-world (Watts–Strogatz)")) +
scale_shape_manual(values = c("ER" = 19, "BA" = 17, "WS" = 15),
labels = c("random (Erdős–Rényi)",
"scale-free (Barabási–Albert)",
"small-world (Watts–Strogatz)")) +
labs(x = expression(bold("PC2 (average degree)")),
y = expression(paste(bold("Average selective pressure "), "|", bold(p), "|")),
title = coef_pval_explVar2_title,
subtitle = R2m_absOutStr_text,
color = "Topology",
shape = "Topology") +
annotate('text', x = -3, y = 0.95, label = MI_obs_explVar2_title_with_pval, parse = TRUE, size = 4, hjust = 0) +
scale_x_continuous(n.breaks = 4) +
ylim(0, 1)
plot_PC2_selpress_sel
## Smoothing formula not specified. Using: y ~ x
## Smoothing formula not specified. Using: y ~ x
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
jointTitle_sel <- ggdraw() + draw_label("Selection",
size = 20,
fontface = 'bold')
jointTitle_neu <- ggdraw() + draw_label("Neutrality",
size = 20,
fontface = 'bold')
jointTitle_combined <- cowplot::plot_grid(NULL, jointTitle_sel, NULL,
NULL, jointTitle_neu, NULL,
labels = c("", "", "", "", "", ""),
ncol = 6,
rel_widths = c(0.5, 1, 0.5, 0.5, 1, 0.5))
plot_netPropertiesFigure_body <- ggpubr::ggarrange(plot_PC1_selpress_sel, plot_PC2_selpress_sel,
plot_PC1_selpress_neu, plot_PC2_selpress_neu,
labels = "AUTO", font.label = list(size = 20, face = "bold"),
ncol = 4, nrow = 1,
common.legend = TRUE, legend = "bottom")
## Smoothing formula not specified. Using: y ~ x
## Smoothing formula not specified. Using: y ~ x
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
## Smoothing formula not specified. Using: y ~ x
## Smoothing formula not specified. Using: y ~ x
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
## Smoothing formula not specified. Using: y ~ x
## Smoothing formula not specified. Using: y ~ x
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
## Warning in is.na(x): is.na() applied to non-(list or vector) of type
## 'expression'
plot_netPropertiesFigure <- cowplot::plot_grid(jointTitle_combined,
plot_netPropertiesFigure_body,
ncol = 1,
rel_heights = c(0.1, 1))
ggsave(filename = sprintf("plot_netPropertiesFigure.png"),
plot = plot_netPropertiesFigure,
bg = "white",
path = pathToPlotsFolder,
device = "png",
scale = 2.1, height = 800, width = 2250, units = "px",
dpi = 300, limitsize = TRUE)
ggsave(filename = sprintf("plot_netPropertiesFigure.tiff"),
plot = plot_netPropertiesFigure,
bg = "white",
path = pathToPlotsFolder,
device = "tiff",
scale = 2.1, height = 900, width = 2250, units = "px",
dpi = 300, limitsize = TRUE)
sessionInfo()
## R version 3.6.3 (2020-02-29)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 18.04.5 LTS
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3
## LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_GB.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_GB.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] dplyr_1.0.7 rstatix_0.7.0 FSA_0.9.3 factoextra_1.0.7
## [5] ade4_1.7-15 corrplot_0.90 Hmisc_4.3-1 Formula_1.2-3
## [9] survival_3.2-7 lattice_0.20-38 reshape2_1.4.3 latex2exp_0.4.0
## [13] RColorBrewer_1.1-2 car_3.0-11 carData_3.0-4 lme4_1.1-27.1
## [17] Matrix_1.2-18 infotheo_1.2.0 cowplot_1.1.1 gridExtra_2.3
## [21] ggridges_0.5.2 ggpubr_0.4.0 ggplot2_3.3.5 MuMIn_1.43.17
## [25] nlme_3.1-144 rmarkdown_2.10
##
## loaded via a namespace (and not attached):
## [1] matrixStats_0.60.0 tools_3.6.3 backports_1.2.1
## [4] bslib_0.2.5.1 utf8_1.2.2 R6_2.5.1
## [7] rpart_4.1-15 DBI_1.1.0 colorspace_2.0-2
## [10] nnet_7.3-12 withr_2.4.2 tidyselect_1.1.1
## [13] curl_4.3.2 compiler_3.6.3 quantreg_5.86
## [16] htmlTable_1.13.3 SparseM_1.81 labeling_0.4.2
## [19] sass_0.4.0 scales_1.1.1 checkmate_2.0.0
## [22] stringr_1.4.0 digest_0.6.28 foreign_0.8-75
## [25] minqa_1.2.4 rio_0.5.27 base64enc_0.1-3
## [28] jpeg_0.1-8.1 pkgconfig_2.0.3 htmltools_0.5.2
## [31] dunn.test_1.3.5 highr_0.9 fastmap_1.1.0
## [34] htmlwidgets_1.5.3 rlang_0.4.12 readxl_1.3.1
## [37] rstudioapi_0.13 farver_2.1.0 jquerylib_0.1.4
## [40] generics_0.1.0 jsonlite_1.7.2 acepack_1.4.1
## [43] zip_2.2.0 magrittr_2.0.1 Rcpp_1.0.7
## [46] munsell_0.5.0 fansi_0.5.0 abind_1.4-5
## [49] lifecycle_1.0.1 stringi_1.7.3 yaml_2.2.1
## [52] MASS_7.3-57 plyr_1.8.6 grid_3.6.3
## [55] ggrepel_0.9.1 forcats_0.5.1 crayon_1.4.2
## [58] haven_2.4.3 splines_3.6.3 hms_1.1.0
## [61] knitr_1.33 pillar_1.6.4 boot_1.3-25
## [64] ggsignif_0.6.2 stats4_3.6.3 glue_1.5.0
## [67] evaluate_0.14 latticeExtra_0.6-29 data.table_1.14.0
## [70] vctrs_0.3.8 png_0.1-7 nloptr_1.2.2.2
## [73] MatrixModels_0.5-0 cellranger_1.1.0 gtable_0.3.0
## [76] purrr_0.3.4 tidyr_1.1.3 xfun_0.25
## [79] openxlsx_4.2.4 broom_0.7.9 conquer_1.0.2
## [82] tibble_3.1.6 cluster_2.1.0 ellipsis_0.3.2
packageVersion('igraph')
## [1] '1.2.4.2'
packageVersion('intergraph')
## [1] '2.0.2'
packageVersion('lme4')
## [1] '1.1.27.1'
packageVersion('nlme')
## [1] '3.1.144'
packageVersion('MuMIn')
## [1] '1.43.17'
packageVersion('infotheo')
## [1] '1.2.0'
packageVersion('car')
## [1] '3.0.11'
packageVersion('ade4')
## [1] '1.7.15'